mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 01:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,37 @@
|
||||
package pet
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class GuiPet extends PetBase
|
||||
{
|
||||
|
||||
public var idx:int;
|
||||
|
||||
private var _petName:String;
|
||||
|
||||
private var _onPetLoadedCallback:Function;
|
||||
|
||||
public function GuiPet(param1:int, param2:uint, param3:uint, param4:uint, param5:int, param6:String, param7:Function)
|
||||
{
|
||||
_onPetLoadedCallback = param7;
|
||||
super(param2,param3,param4,onPetLoaded);
|
||||
this.idx = param1;
|
||||
_petName = param6;
|
||||
}
|
||||
|
||||
public function get petName() : String
|
||||
{
|
||||
return LocalizationManager.translatePetName(_petName);
|
||||
}
|
||||
|
||||
private function onPetLoaded(param1:MovieClip) : void
|
||||
{
|
||||
if(_onPetLoadedCallback != null)
|
||||
{
|
||||
_onPetLoadedCallback(param1,this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
package pet
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class PetBase extends Sprite
|
||||
{
|
||||
|
||||
public static const DEF_ID_CAT:int = 1;
|
||||
|
||||
public static const DEF_ID_FROG:int = 2;
|
||||
|
||||
public static const DEF_ID_DUCK:int = 3;
|
||||
|
||||
public static const DEF_ID_DOG:int = 4;
|
||||
|
||||
public static const DEF_ID_BFLY:int = 5;
|
||||
|
||||
public static const DEF_ID_HAMS:int = 6;
|
||||
|
||||
public static const DEF_ID_BAT:int = 7;
|
||||
|
||||
public static const DEF_ID_SEAHORSE:int = 8;
|
||||
|
||||
public static const DEF_ID_ANGLER:int = 9;
|
||||
|
||||
public static const DEF_ID_REINDEER:int = 10;
|
||||
|
||||
public static const DEF_ID_SNAKE:int = 11;
|
||||
|
||||
public static const DEF_ID_JELLYFISH:int = 12;
|
||||
|
||||
public static const DEF_ID_BUNNY:int = 13;
|
||||
|
||||
public static const DEF_ID_HUMMINGBIRD:int = 14;
|
||||
|
||||
public static const DEF_ID_TURTLE:int = 15;
|
||||
|
||||
public static const DEF_ID_MONKEY:int = 16;
|
||||
|
||||
public static const DEF_ID_TARANTUAL:int = 17;
|
||||
|
||||
public static const DEF_ID_FOX:int = 18;
|
||||
|
||||
public static const DEF_ID_OWL:int = 19;
|
||||
|
||||
public static const DEF_ID_TIGER:int = 20;
|
||||
|
||||
public static const DEF_ID_ARCTIC_WOLF:int = 21;
|
||||
|
||||
public static const DEF_ID_RACCOON:int = 22;
|
||||
|
||||
public static const DEF_ID_JOEY:int = 23;
|
||||
|
||||
public static const DEF_ID_EAGLET:int = 24;
|
||||
|
||||
public static const DEF_ID_CHEETAH:int = 25;
|
||||
|
||||
public static const DEF_ID_RHINO:int = 26;
|
||||
|
||||
public static const DEF_ID_GIRAFFE:int = 27;
|
||||
|
||||
public static const DEF_ID_SUGAR_GLIDER:int = 28;
|
||||
|
||||
public static const DEF_ID_LION_CUB:int = 29;
|
||||
|
||||
public static const DEF_ID_PANDA:int = 30;
|
||||
|
||||
public static const DEF_ID_POLAR_BEAR_CUB:int = 31;
|
||||
|
||||
public static const DEF_ID_GECKO:int = 32;
|
||||
|
||||
public static const DEF_ID_PONY:int = 34;
|
||||
|
||||
public static const DEF_ID_PIGLET:int = 35;
|
||||
|
||||
public static const DEF_ID_FERRET:int = 36;
|
||||
|
||||
public static const DEF_ID_ELEPHANT:int = 37;
|
||||
|
||||
public static const DEF_ID_ARMADILLO:int = 38;
|
||||
|
||||
public static const DEF_ID_PEACOCK:int = 39;
|
||||
|
||||
public static const DEF_ID_BEE:int = 40;
|
||||
|
||||
public static const DEF_ID_SKUNK:int = 42;
|
||||
|
||||
public static const DEF_ID_TURKEY:int = 43;
|
||||
|
||||
public static const DEF_ID_PENGUIN:int = 44;
|
||||
|
||||
public static const DEF_ID_SNOW_LEOPARD:int = 45;
|
||||
|
||||
public static const TYPE_LAND_GROUND:int = 0;
|
||||
|
||||
public static const TYPE_LAND_AIR:int = 1;
|
||||
|
||||
public static const TYPE_OCEAN_GROUND:int = 2;
|
||||
|
||||
public static const TYPE_OCEAN_AIR:int = 3;
|
||||
|
||||
public static const TYPE_AMPHIB_GROUND:int = 4;
|
||||
|
||||
public static const TYPE_AMPHIB_AIR:int = 5;
|
||||
|
||||
protected var _type:int;
|
||||
|
||||
protected var _defId:int;
|
||||
|
||||
protected var _lBits:uint;
|
||||
|
||||
protected var _uBits:uint;
|
||||
|
||||
protected var _eBits:uint;
|
||||
|
||||
protected var _content:MovieClip;
|
||||
|
||||
private var _mediaHelper:MediaHelper;
|
||||
|
||||
private var _onPetLoadedCallback:Function;
|
||||
|
||||
public function PetBase(param1:uint, param2:uint, param3:uint, param4:Function)
|
||||
{
|
||||
super();
|
||||
_lBits = param1;
|
||||
_uBits = param2;
|
||||
_eBits = param3;
|
||||
_onPetLoadedCallback = param4;
|
||||
_defId = param1 & 0xFF;
|
||||
_type = PetManager.petTypeForDefId(_defId);
|
||||
_mediaHelper = new MediaHelper();
|
||||
_mediaHelper.init(mediaIdForDefId(_defId),onMediaLoaded,true);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function isGround() : Boolean
|
||||
{
|
||||
return PetManager.isGround(_type);
|
||||
}
|
||||
|
||||
public function getType() : int
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
public function getDefID() : int
|
||||
{
|
||||
return _defId;
|
||||
}
|
||||
|
||||
public function canGoInOcean() : Boolean
|
||||
{
|
||||
if(_type == 2 || _type == 3 || _type == 4 || _type == 5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function canGoOnLand() : Boolean
|
||||
{
|
||||
if(_type == 0 || _type == 1 || _type == 4 || _type == 5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getLBits() : uint
|
||||
{
|
||||
return _lBits;
|
||||
}
|
||||
|
||||
public function getUBits() : uint
|
||||
{
|
||||
return _uBits;
|
||||
}
|
||||
|
||||
public function getEBits() : uint
|
||||
{
|
||||
return _eBits;
|
||||
}
|
||||
|
||||
public function getContent() : MovieClip
|
||||
{
|
||||
return _content;
|
||||
}
|
||||
|
||||
public function colorMyItem(param1:int, param2:MovieClip, param3:int, param4:int, param5:int, param6:int, param7:int, param8:int) : void
|
||||
{
|
||||
if(_content)
|
||||
{
|
||||
_content.colorMe(param1,param2,param3,param4,param5,param6,param7,param8);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateAllBits(param1:uint, param2:uint, param3:uint) : void
|
||||
{
|
||||
if(_content)
|
||||
{
|
||||
_lBits = param1;
|
||||
_uBits = param2;
|
||||
_eBits = param3;
|
||||
PetManager.setPetState(_content,_lBits,_uBits,_eBits);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateUBits(param1:uint) : void
|
||||
{
|
||||
_uBits = param1;
|
||||
PetManager.setPetState(_content,_lBits,_uBits,_eBits);
|
||||
}
|
||||
|
||||
public function animatePet(param1:Boolean) : void
|
||||
{
|
||||
if(_content && "willItAnimate" in _content.pet)
|
||||
{
|
||||
_content.pet.willItAnimate(param1);
|
||||
}
|
||||
}
|
||||
|
||||
protected function setSparkle(param1:int) : void
|
||||
{
|
||||
if(_content)
|
||||
{
|
||||
_content.pet.setSparkle(param1);
|
||||
}
|
||||
}
|
||||
|
||||
private function onMediaLoaded(param1:MovieClip) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
_content = param1;
|
||||
this.addChild(_content);
|
||||
_mediaHelper.destroy();
|
||||
delete _content.mediaHelper;
|
||||
delete _content.passback;
|
||||
PetManager.setPetState(_content,_lBits,_uBits,_eBits);
|
||||
if(_onPetLoadedCallback != null)
|
||||
{
|
||||
_onPetLoadedCallback(_content);
|
||||
}
|
||||
_content.pet.setAnim(0);
|
||||
}
|
||||
}
|
||||
|
||||
private function mediaIdForDefId(param1:int) : int
|
||||
{
|
||||
var _loc2_:Object = PetManager.getPetDef(param1);
|
||||
if(_loc2_)
|
||||
{
|
||||
return _loc2_.mediaRefId;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,951 @@
|
||||
package pet
|
||||
{
|
||||
import Party.PartyManager;
|
||||
import avatar.AvatarInfo;
|
||||
import avatar.AvatarManager;
|
||||
import avatar.AvatarWorldView;
|
||||
import avatar.UserCommXtCommManager;
|
||||
import avatar.UserInfo;
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import currency.UserCurrency;
|
||||
import den.DenXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import gui.PetCreator;
|
||||
import gui.PetMastery;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class PetManager
|
||||
{
|
||||
|
||||
public static const TYPE_LAND_LOW:int = 0;
|
||||
|
||||
public static const TYPE_LAND_HIGH:int = 1;
|
||||
|
||||
public static const TYPE_OCEAN_LOW:int = 2;
|
||||
|
||||
public static const TYPE_OCEAN_HIGH:int = 3;
|
||||
|
||||
public static const TYPE_AMPHIB_LOW:int = 4;
|
||||
|
||||
public static const TYPE_AMPHIB_HIGH:int = 5;
|
||||
|
||||
public static const LIMITED_TIME:int = 1;
|
||||
|
||||
public static const MASTERY_ACHIV_MIN_COUNT:int = 100;
|
||||
|
||||
private static const EVT_ICON_ID:int = 44;
|
||||
|
||||
private static var _petDefs:Object;
|
||||
|
||||
private static var _myPetList:Array;
|
||||
|
||||
private static var _myActivePetInvId:int;
|
||||
|
||||
private static var _petFinderCloseCallback:Function;
|
||||
|
||||
private static var _petFinder:PetCreator;
|
||||
|
||||
private static var _petMasteryMgr:PetMastery;
|
||||
|
||||
private static var _petFinderCallback:Function;
|
||||
|
||||
public function PetManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
_myPetList = [];
|
||||
}
|
||||
|
||||
public static function set petDefs(param1:Object) : void
|
||||
{
|
||||
_petDefs = param1;
|
||||
}
|
||||
|
||||
public static function relocalizePetDefs() : void
|
||||
{
|
||||
for each(var _loc1_:Object in _petDefs)
|
||||
{
|
||||
_loc1_.title = LocalizationManager.translateIdOnly(_loc1_.titleStrId);
|
||||
}
|
||||
}
|
||||
|
||||
public static function openPetFinder(param1:String = "", param2:Function = null, param3:Boolean = false, param4:Array = null, param5:Object = null, param6:int = 0, param7:int = 0, param8:Boolean = false) : void
|
||||
{
|
||||
if(_petFinder)
|
||||
{
|
||||
_petFinder.destroy();
|
||||
_petFinder = null;
|
||||
}
|
||||
_petFinder = new PetCreator();
|
||||
_petFinderCallback = param2;
|
||||
if(param1 == "")
|
||||
{
|
||||
_petFinder.init(-1,onPetFinderClose,false,null,param6,null,param7);
|
||||
}
|
||||
else
|
||||
{
|
||||
_petFinder.init(petDefIdForName(param1),onPetFinderClose,param3,param4,param6,param5,param7,param8);
|
||||
}
|
||||
}
|
||||
|
||||
private static function onPetFinderClose() : void
|
||||
{
|
||||
if(_petFinder)
|
||||
{
|
||||
_petFinder.destroy();
|
||||
_petFinder = null;
|
||||
}
|
||||
if(_petFinderCallback != null)
|
||||
{
|
||||
_petFinderCallback();
|
||||
_petFinderCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function checkAndOpenMasteryPopup(param1:Boolean) : void
|
||||
{
|
||||
if(myActivePet && myActivePet.masteryCounter >= 100 && param1)
|
||||
{
|
||||
if(!_petMasteryMgr)
|
||||
{
|
||||
_petMasteryMgr = new PetMastery();
|
||||
_petMasteryMgr.init();
|
||||
}
|
||||
_petMasteryMgr.displayMasteryPopup();
|
||||
}
|
||||
}
|
||||
|
||||
public static function onPetListResponse(param1:Array, param2:Function) : void
|
||||
{
|
||||
var _loc5_:Array = null;
|
||||
var _loc8_:String = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:Object = null;
|
||||
var _loc7_:int = 0;
|
||||
var _loc10_:int = 0;
|
||||
var _loc9_:int = 2;
|
||||
var _loc6_:String = param1[_loc9_++];
|
||||
if(_loc6_ == "1")
|
||||
{
|
||||
_loc8_ = param1[_loc9_++];
|
||||
_loc4_ = int(param1[_loc9_++]);
|
||||
_loc5_ = [];
|
||||
_loc7_ = -1;
|
||||
_loc10_ = 0;
|
||||
while(_loc10_ < _loc4_)
|
||||
{
|
||||
_loc3_ = {
|
||||
"idx":int(param1[_loc9_++]),
|
||||
"name":param1[_loc9_++],
|
||||
"isGround":isGround(param1[_loc9_++]),
|
||||
"lBits":uint(param1[_loc9_++]),
|
||||
"uBits":uint(param1[_loc9_++]),
|
||||
"eBits":uint(param1[_loc9_++]),
|
||||
"masteryCounter":uint(param1[_loc9_++]),
|
||||
"isSparkling":false
|
||||
};
|
||||
_loc3_.defId = getDefIdFromLBits(_loc3_.lBits);
|
||||
_loc3_.type = petTypeForDefId(_loc3_.defId);
|
||||
_loc5_.push(_loc3_);
|
||||
_loc10_++;
|
||||
}
|
||||
_loc5_.sortOn("idx",16);
|
||||
if(_loc8_.toLowerCase() == gMainFrame.userInfo.myUserName.toLowerCase())
|
||||
{
|
||||
_myPetList = _loc5_;
|
||||
}
|
||||
}
|
||||
if(param2 != null)
|
||||
{
|
||||
param2(_loc5_,_loc6_);
|
||||
}
|
||||
}
|
||||
|
||||
public static function isGround(param1:int) : Boolean
|
||||
{
|
||||
return param1 == 0 || param1 == 2 || param1 == 4;
|
||||
}
|
||||
|
||||
public static function onPetCreateResponse(param1:Array, param2:Function) : void
|
||||
{
|
||||
var _loc8_:int = 0;
|
||||
var _loc13_:int = 0;
|
||||
var _loc6_:* = undefined;
|
||||
var _loc9_:int = 0;
|
||||
var _loc3_:* = 0;
|
||||
var _loc12_:* = 0;
|
||||
var _loc11_:* = 0;
|
||||
var _loc10_:String = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:Object = null;
|
||||
var _loc7_:Object = null;
|
||||
var _loc14_:int = 2;
|
||||
if(param1[_loc14_++] == "1")
|
||||
{
|
||||
_loc8_ = int(param1[_loc14_++]);
|
||||
_loc13_ = int(param1[_loc14_++]);
|
||||
_loc6_ = UserCurrency.getCurrency(_loc13_);
|
||||
if(_loc6_ == null)
|
||||
{
|
||||
throw new Error("ItemManager: Received unknown currencyType: " + _loc13_);
|
||||
}
|
||||
UserCurrency.setCurrency(_loc8_,_loc13_);
|
||||
if(_loc6_ != _loc8_)
|
||||
{
|
||||
AJAudio.playShopCachingSound();
|
||||
}
|
||||
_loc9_ = int(param1[_loc14_++]);
|
||||
_loc3_ = uint(param1[_loc14_++]);
|
||||
_loc12_ = uint(param1[_loc14_++]);
|
||||
_loc11_ = uint(param1[_loc14_++]);
|
||||
_loc10_ = param1[_loc14_++];
|
||||
_loc4_ = getDefIdFromLBits(_loc3_);
|
||||
_loc5_ = getPetDef(_loc4_);
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc7_ = {
|
||||
"idx":_loc9_,
|
||||
"name":_loc10_,
|
||||
"defId":_loc4_,
|
||||
"type":_loc5_.type,
|
||||
"lBits":_loc3_,
|
||||
"uBits":_loc12_,
|
||||
"eBits":_loc11_,
|
||||
"isSparkling":false
|
||||
};
|
||||
_loc7_.masteryCounter = 0;
|
||||
_myPetList.push(_loc7_);
|
||||
DenXtCommManager.addPetToDen(_loc7_);
|
||||
if(PetManager.canCurrAvatarUsePet(AvatarManager.playerAvatar.enviroTypeFlag,_loc5_.type))
|
||||
{
|
||||
if(!_loc5_.isMember || Boolean(gMainFrame.userInfo.isMember))
|
||||
{
|
||||
AvatarManager.playerAvatarWorldView.setActivePet(_loc3_,_loc12_,_loc11_,_loc10_);
|
||||
myActivePetInvId = _loc9_;
|
||||
}
|
||||
AvatarManager.setPetAction(AvatarManager.playerSfsUserId,1,0);
|
||||
}
|
||||
if(param2 != null)
|
||||
{
|
||||
param2();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14809));
|
||||
}
|
||||
}
|
||||
|
||||
public static function onPetSwitchResponse(param1:Array, param2:Function) : void
|
||||
{
|
||||
var _loc15_:AvatarWorldView = null;
|
||||
var _loc17_:int = 0;
|
||||
var _loc13_:Boolean = false;
|
||||
var _loc7_:* = null;
|
||||
var _loc3_:UserInfo = null;
|
||||
var _loc4_:Object = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc11_:int = 0;
|
||||
var _loc10_:int = 0;
|
||||
var _loc9_:String = null;
|
||||
var _loc14_:Object = null;
|
||||
var _loc16_:AvatarInfo = null;
|
||||
var _loc12_:int = 2;
|
||||
var _loc6_:Boolean = param1[_loc12_++] == "1";
|
||||
if(_loc6_)
|
||||
{
|
||||
_loc17_ = int(param1[_loc12_++]);
|
||||
_loc15_ = AvatarManager.getAvatarWorldViewBySfsUserId(_loc17_);
|
||||
if(_loc17_ == gMainFrame.server.userId)
|
||||
{
|
||||
myActivePetInvId = int(param1[_loc12_++]);
|
||||
if(_loc15_)
|
||||
{
|
||||
if(myActivePetInvId != 0)
|
||||
{
|
||||
for each(_loc7_ in _myPetList)
|
||||
{
|
||||
if(_loc7_.idx == myActivePetInvId)
|
||||
{
|
||||
_loc15_.setActivePet(_loc7_.lBits,_loc7_.uBits,_loc7_.eBits,_loc7_.name);
|
||||
_loc13_ = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc15_.setActivePet(0,0,0,"");
|
||||
}
|
||||
_loc3_ = gMainFrame.userInfo.getUserInfoByUserName(_loc15_.userName);
|
||||
for each(var _loc8_:AvatarInfo in _loc3_.avList)
|
||||
{
|
||||
if(_loc8_.perUserAvId == _loc15_.perUserAvId)
|
||||
{
|
||||
if(AvatarManager.roomEnviroType == 0)
|
||||
{
|
||||
_loc8_.landPetInvId = myActivePetInvId;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_.oceanPetInvId = myActivePetInvId;
|
||||
}
|
||||
gMainFrame.userInfo.setUserInfoByUserName(_loc15_.userName,_loc3_);
|
||||
break;
|
||||
}
|
||||
}
|
||||
AvatarManager.setPetAction(AvatarManager.playerSfsUserId,1,0);
|
||||
_loc4_ = myActivePet;
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc15_.setActivePet(_loc4_.lBits,_loc4_.uBits,_loc4_.eBits,_loc4_.name);
|
||||
_loc4_.isSparkling = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = int(param1[_loc12_++]);
|
||||
_loc11_ = int(param1[_loc12_++]);
|
||||
_loc10_ = int(param1[_loc12_++]);
|
||||
_loc9_ = param1[_loc12_++];
|
||||
if(_loc15_)
|
||||
{
|
||||
_loc15_.setActivePet(_loc5_,_loc11_,_loc11_,_loc9_);
|
||||
}
|
||||
_loc14_ = null;
|
||||
if(_loc5_ != 0)
|
||||
{
|
||||
_loc14_ = {
|
||||
"name":_loc9_,
|
||||
"lBits":_loc5_,
|
||||
"uBits":_loc11_,
|
||||
"eBits":_loc10_
|
||||
};
|
||||
_loc14_.defId = PetManager.getDefIdFromLBits(_loc14_.lBits);
|
||||
_loc14_.type = PetManager.petTypeForDefId(_loc14_.defId);
|
||||
_loc14_.isGround = PetManager.isGround(_loc14_.type);
|
||||
}
|
||||
_loc16_ = gMainFrame.userInfo.getAvatarInfoByUserName(_loc15_.userName);
|
||||
if(_loc16_)
|
||||
{
|
||||
_loc16_.currPet = _loc14_;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14810));
|
||||
}
|
||||
if(param2 != null)
|
||||
{
|
||||
param2(_loc6_);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onPetItemsResponse(param1:Array, param2:Function) : void
|
||||
{
|
||||
var _loc4_:Object = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc8_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc9_:int = 2;
|
||||
var _loc5_:Boolean = param1[_loc9_++] == "1";
|
||||
if(_loc5_)
|
||||
{
|
||||
UserCurrency.setCurrency(int(param1[_loc9_++]),0);
|
||||
AJAudio.playShopCachingSound();
|
||||
_loc4_ = myActivePet;
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
trace("ERROR: myActivePet is null");
|
||||
return;
|
||||
}
|
||||
_loc6_ = int(param1[_loc9_++]);
|
||||
if(myActivePet.idx != _loc6_)
|
||||
{
|
||||
trace("ERROR: Invalid pet invId");
|
||||
return;
|
||||
}
|
||||
_loc3_ = int(param1[_loc9_++]);
|
||||
_loc8_ = int(param1[_loc9_++]);
|
||||
_loc7_ = int(param1[_loc9_++]);
|
||||
_loc4_.lBits = _loc3_;
|
||||
_loc4_.uBits = _loc8_;
|
||||
_loc4_.eBits = _loc7_;
|
||||
AvatarManager.playerAvatarWorldView.setActivePet(_loc3_,_loc8_,_loc7_,myActivePetName);
|
||||
myActivePetInvId = _loc6_;
|
||||
DenXtCommManager.reloadPetInDen(_loc6_,_loc3_,_loc8_,_loc7_);
|
||||
}
|
||||
if(param2 != null)
|
||||
{
|
||||
param2(_loc5_);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onPetMasteryResponse(param1:Array, param2:Function) : void
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc9_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc6_:int = 0;
|
||||
var _loc8_:int = 2;
|
||||
var _loc4_:Boolean = param1[_loc8_++] == "1";
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc5_ = int(param1[_loc8_++]);
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < _myPetList.length)
|
||||
{
|
||||
if(_myPetList[_loc9_].idx == _loc5_)
|
||||
{
|
||||
_loc3_ = int(param1[_loc8_++]);
|
||||
_loc7_ = int(param1[_loc8_++]);
|
||||
_loc6_ = int(param1[_loc8_++]);
|
||||
_myPetList[_loc9_].lBits = _loc3_;
|
||||
_myPetList[_loc9_].uBits = _loc7_;
|
||||
_myPetList[_loc9_].eBits = _loc6_;
|
||||
DenXtCommManager.reloadPetInDen(_loc5_,_loc3_,_loc7_,_loc6_);
|
||||
break;
|
||||
}
|
||||
_loc9_++;
|
||||
}
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(param2 != null)
|
||||
{
|
||||
param2(_loc4_);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onPetDismissResponse(param1:Array, param2:Function) : void
|
||||
{
|
||||
var _loc3_:Boolean = false;
|
||||
var _loc5_:Boolean = false;
|
||||
var _loc7_:int = 0;
|
||||
var _loc4_:Boolean = param1[2] == "1";
|
||||
var _loc6_:int = int(param1[3]);
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _myPetList.length)
|
||||
{
|
||||
if(_myPetList[_loc7_].idx == _loc6_)
|
||||
{
|
||||
if(_myActivePetInvId == _myPetList[_loc7_].idx)
|
||||
{
|
||||
_myActivePetInvId = 0;
|
||||
AvatarManager.playerAvatarWorldView.setActivePet(0,0,0,"");
|
||||
_loc5_ = true;
|
||||
AvatarManager.setPetAction(AvatarManager.playerSfsUserId,1,0);
|
||||
}
|
||||
_myPetList.splice(_loc7_,1);
|
||||
DenXtCommManager.removePetFromDen(_loc6_);
|
||||
_loc3_ = true;
|
||||
break;
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14786));
|
||||
}
|
||||
if(param2 != null)
|
||||
{
|
||||
param2(_loc4_,_loc3_,_loc5_);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getPetSprite(param1:uint, param2:uint, param3:uint, param4:int, param5:Function = null) : Sprite
|
||||
{
|
||||
return Sprite(new PetBase(param1,param2,param3,param5));
|
||||
}
|
||||
|
||||
public static function getGuiPet(param1:int, param2:uint, param3:uint, param4:uint, param5:int, param6:String, param7:Function = null) : GuiPet
|
||||
{
|
||||
return new GuiPet(param1,param2,param3,param4,param5,param6,param7);
|
||||
}
|
||||
|
||||
public static function get myPetList() : Array
|
||||
{
|
||||
return _myPetList;
|
||||
}
|
||||
|
||||
public static function get myActivePetName() : String
|
||||
{
|
||||
var _loc1_:Object = getMyPetByInvId(_myActivePetInvId);
|
||||
if(_loc1_)
|
||||
{
|
||||
return _loc1_.name;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function set myActivePetInvId(param1:int) : void
|
||||
{
|
||||
_myActivePetInvId = param1;
|
||||
}
|
||||
|
||||
public static function addToActivePetMastery(param1:int) : void
|
||||
{
|
||||
myActivePet.masteryCounter += param1;
|
||||
}
|
||||
|
||||
public static function get myActivePetInvId() : int
|
||||
{
|
||||
return _myActivePetInvId;
|
||||
}
|
||||
|
||||
public static function getMyPetByInvId(param1:int) : Object
|
||||
{
|
||||
var _loc2_:* = null;
|
||||
for each(_loc2_ in _myPetList)
|
||||
{
|
||||
if(_loc2_.idx == param1)
|
||||
{
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function get myActivePet() : Object
|
||||
{
|
||||
var _loc1_:* = null;
|
||||
for each(_loc1_ in _myPetList)
|
||||
{
|
||||
if(_loc1_.idx == _myActivePetInvId)
|
||||
{
|
||||
return _loc1_;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function petTypeForDefId(param1:int) : int
|
||||
{
|
||||
if(_petDefs && _petDefs[param1])
|
||||
{
|
||||
return _petDefs[param1].type;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static function getPetDef(param1:int) : Object
|
||||
{
|
||||
if(_petDefs)
|
||||
{
|
||||
return _petDefs[param1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function petForPetDefId(param1:int) : Object
|
||||
{
|
||||
var _loc2_:* = null;
|
||||
for each(_loc2_ in _myPetList)
|
||||
{
|
||||
if(_loc2_.defId == param1)
|
||||
{
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getEnviroTypeByPetType(param1:int, param2:int = 0) : int
|
||||
{
|
||||
if(param1 == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(param1 == 1)
|
||||
{
|
||||
return Utility.isAir(param2) ? 2 : 0;
|
||||
}
|
||||
if(param1 == 3 || param1 == 2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if(param1 == 4 || param1 == 5)
|
||||
{
|
||||
return AvatarManager.roomEnviroType;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static function setPetState(param1:MovieClip, param2:uint, param3:uint, param4:uint) : void
|
||||
{
|
||||
var _loc5_:int = param2 & 0xFF;
|
||||
if(PetManager.petTypeForDefId(_loc5_) == 4)
|
||||
{
|
||||
param1.pet.setState(param2,param3,param4,AvatarManager.roomEnviroType);
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.pet.setState(param2,param3);
|
||||
}
|
||||
}
|
||||
|
||||
public static function petDefIdForName(param1:String) : int
|
||||
{
|
||||
switch(param1)
|
||||
{
|
||||
case "frog":
|
||||
return 2;
|
||||
case "kitten":
|
||||
return 1;
|
||||
case "puppy":
|
||||
return 4;
|
||||
case "ducky":
|
||||
return 3;
|
||||
case "butterfly":
|
||||
return 5;
|
||||
case "hamster":
|
||||
return 6;
|
||||
case "bat":
|
||||
return 7;
|
||||
case "seahorse":
|
||||
return 8;
|
||||
case "anglerfish":
|
||||
return 9;
|
||||
case "reindeer":
|
||||
return 10;
|
||||
case "snake":
|
||||
return 11;
|
||||
case "jellyfish":
|
||||
return 12;
|
||||
case "bunny":
|
||||
return 13;
|
||||
case "hummingbird":
|
||||
return 14;
|
||||
case "turtle":
|
||||
return 15;
|
||||
case "monkey":
|
||||
return 16;
|
||||
case "tarantula":
|
||||
return 17;
|
||||
case "fox":
|
||||
return 18;
|
||||
case "owl":
|
||||
return 19;
|
||||
case "tiger":
|
||||
return 20;
|
||||
case "arcticwolfpup":
|
||||
return 21;
|
||||
case "raccoon":
|
||||
return 22;
|
||||
case "joey":
|
||||
return 23;
|
||||
case "eaglet":
|
||||
return 24;
|
||||
case "cheetah":
|
||||
return 25;
|
||||
case "rhino":
|
||||
return 26;
|
||||
case "giraffe":
|
||||
return 27;
|
||||
case "sugarglider":
|
||||
return 28;
|
||||
case "lionCub":
|
||||
return 29;
|
||||
case "panda":
|
||||
return 30;
|
||||
case "polarBearCub":
|
||||
return 31;
|
||||
case "gecko":
|
||||
return 32;
|
||||
case "pony":
|
||||
return 34;
|
||||
case "piglet":
|
||||
return 35;
|
||||
case "ferret":
|
||||
return 36;
|
||||
case "elephant":
|
||||
return 37;
|
||||
case "armadillo":
|
||||
return 38;
|
||||
case "peacock":
|
||||
return 39;
|
||||
case "bee":
|
||||
return 40;
|
||||
case "skunk":
|
||||
return 42;
|
||||
case "turkey":
|
||||
return 43;
|
||||
case "penguin":
|
||||
return 44;
|
||||
case "snowLeopard":
|
||||
return 45;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static function petNameForDefId(param1:int) : String
|
||||
{
|
||||
switch(param1)
|
||||
{
|
||||
case 2:
|
||||
return "frog";
|
||||
case 1:
|
||||
return "kitten";
|
||||
case 4:
|
||||
return "puppy";
|
||||
case 3:
|
||||
return "ducky";
|
||||
case 5:
|
||||
return "butterfly";
|
||||
case 6:
|
||||
return "hamster";
|
||||
case 7:
|
||||
return "bat";
|
||||
case 8:
|
||||
return "seahorse";
|
||||
case 9:
|
||||
return "anglerfish";
|
||||
case 10:
|
||||
return "reindeer";
|
||||
case 11:
|
||||
return "snake";
|
||||
case 12:
|
||||
return "jellyfish";
|
||||
case 13:
|
||||
return "bunny";
|
||||
case 14:
|
||||
return "hummingbird";
|
||||
case 15:
|
||||
return "turtle";
|
||||
case 16:
|
||||
return "monkey";
|
||||
case 17:
|
||||
return "tarantula";
|
||||
case 18:
|
||||
return "fox";
|
||||
case 19:
|
||||
return "owl";
|
||||
case 20:
|
||||
return "tiger";
|
||||
case 21:
|
||||
return "arcticwolfpup";
|
||||
case 22:
|
||||
return "raccoon";
|
||||
case 23:
|
||||
return "joey";
|
||||
case 24:
|
||||
return "eaglet";
|
||||
case 25:
|
||||
return "cheetah";
|
||||
case 26:
|
||||
return "rhino";
|
||||
case 27:
|
||||
return "giraffe";
|
||||
case 28:
|
||||
return "sugarglider";
|
||||
case 29:
|
||||
return "lionCub";
|
||||
case 30:
|
||||
return "panda";
|
||||
case 31:
|
||||
return "polarBearCub";
|
||||
case 32:
|
||||
return "gecko";
|
||||
case 34:
|
||||
return "pony";
|
||||
case 35:
|
||||
return "piglet";
|
||||
case 36:
|
||||
return "ferret";
|
||||
case 37:
|
||||
return "elephant";
|
||||
case 38:
|
||||
return "armadillo";
|
||||
case 39:
|
||||
return "peacock";
|
||||
case 40:
|
||||
return "bee";
|
||||
case 42:
|
||||
return "skunk";
|
||||
case 43:
|
||||
return "turkey";
|
||||
case 44:
|
||||
return "penguin";
|
||||
case 45:
|
||||
return "snowLeopard";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static function getDefIdFromLBits(param1:int) : int
|
||||
{
|
||||
return param1 & 0xFF;
|
||||
}
|
||||
|
||||
public static function sendPetSparkle(param1:int) : void
|
||||
{
|
||||
UserCommXtCommManager.sendPetAction(1,param1);
|
||||
}
|
||||
|
||||
public static function getPetInventoryMax() : Number
|
||||
{
|
||||
return gMainFrame.userInfo.userVarCache.getUserVarValueById(338);
|
||||
}
|
||||
|
||||
public static function isPetAvailable(param1:Number) : Boolean
|
||||
{
|
||||
if(Utility.bitwiseAnd(gMainFrame.userInfo.userVarCache.getUserVarValueById(342),Utility.leftShiftNumbers(param1 - 1)) > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canCurrAvatarUsePet(param1:int, param2:int) : Boolean
|
||||
{
|
||||
var _loc4_:Boolean = false;
|
||||
var _loc3_:Object = null;
|
||||
if(gMainFrame.clientInfo.roomType == 5)
|
||||
{
|
||||
_loc3_ = PartyManager.getPartyDef(gMainFrame.clientInfo.secondaryDefId);
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
if(_loc3_.restrictions == 8)
|
||||
{
|
||||
_loc4_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return canBeUsedInEnviroType(param2,AvatarManager.roomEnviroType) && (_loc4_ ? true : canBeUsedByEnviroTypeFlag(param2,param1));
|
||||
}
|
||||
|
||||
private static function canBeUsedInEnviroType(param1:int, param2:int) : Boolean
|
||||
{
|
||||
if(param1 == 0 || param1 == 1)
|
||||
{
|
||||
return param2 == 0;
|
||||
}
|
||||
if(param1 == 2 || param1 == 3)
|
||||
{
|
||||
return param2 == 1;
|
||||
}
|
||||
if(param1 == 4 || param1 == 5)
|
||||
{
|
||||
return param2 == 0 || param2 == 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function canBeUsedByEnviroTypeFlag(param1:int, param2:int) : Boolean
|
||||
{
|
||||
if(param1 == 0)
|
||||
{
|
||||
return !Utility.isAir(param2) && Utility.isLand(param2);
|
||||
}
|
||||
if(param1 == 1)
|
||||
{
|
||||
return Utility.isAir(param2) || Utility.isLand(param2);
|
||||
}
|
||||
if(param1 == 2 || param1 == 3)
|
||||
{
|
||||
return Utility.isOcean(param2);
|
||||
}
|
||||
if(param1 == 4)
|
||||
{
|
||||
return !Utility.isAir(param2) && (Utility.isLand(param2) || Utility.isOcean(param2));
|
||||
}
|
||||
if(param1 == 5)
|
||||
{
|
||||
return Utility.isLand(param2) || Utility.isOcean(param2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canPetGoInEnviroType(param1:int, param2:int) : Boolean
|
||||
{
|
||||
var _loc3_:int = getEnviroTypeByPetType(param1,param2);
|
||||
if(Utility.isSameEnviroType(param2,_loc3_))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function checkIfHasPet(param1:int) : Boolean
|
||||
{
|
||||
var _loc2_:* = null;
|
||||
var _loc3_:int = 0;
|
||||
for each(_loc2_ in _myPetList)
|
||||
{
|
||||
_loc3_ = getEnviroTypeByPetType(_loc2_.type,param1);
|
||||
if(_loc3_ == 0)
|
||||
{
|
||||
if(Utility.isSameEnviroType(param1,_loc3_) && !Utility.isAir(param1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(Utility.isSameEnviroType(param1,_loc3_))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function createRandomPet(param1:int) : Array
|
||||
{
|
||||
var _loc2_:int = Math.random() * 19;
|
||||
var _loc4_:int = Math.random() * 19;
|
||||
var _loc3_:int = 0;
|
||||
var _loc6_:int = Math.random() * 5;
|
||||
var _loc5_:int = Math.random() * 3;
|
||||
var _loc8_:int = Math.random() * 3;
|
||||
var _loc9_:int = Math.random() * 3;
|
||||
var _loc7_:int = 0;
|
||||
return [param1,_loc2_,_loc4_,_loc3_,_loc6_,_loc5_,_loc8_,_loc9_,_loc7_,0,0,0,0,0,0];
|
||||
}
|
||||
|
||||
public static function packPetBits(param1:Array) : Array
|
||||
{
|
||||
var _loc2_:uint = uint(param1[5] << 28 | param1[4] << 24 | param1[3] << 19 | param1[2] << 14 | param1[1] << 8 | param1[0]);
|
||||
var _loc4_:uint = uint(param1[11] << 20 | param1[10] << 16 | param1[9] << 12 | param1[8] << 8 | param1[7] << 4 | param1[6]);
|
||||
var _loc3_:uint = 0;
|
||||
return [_loc2_,_loc4_,_loc3_];
|
||||
}
|
||||
|
||||
public static function unpackPetBits(param1:uint, param2:uint, param3:uint) : Array
|
||||
{
|
||||
var _loc10_:int = param1 & 0xFF;
|
||||
var _loc11_:int = param1 >> 8 & 0x3F;
|
||||
var _loc13_:int = param1 >> 14 & 0x1F;
|
||||
var _loc12_:int = param1 >> 19 & 0x1F;
|
||||
var _loc16_:int = param1 >> 24 & 0x0F;
|
||||
var _loc14_:int = param1 >> 28 & 0x0F;
|
||||
var _loc8_:int = param2 & 0x0F;
|
||||
var _loc9_:int = param2 >> 4 & 0x0F;
|
||||
var _loc6_:int = param2 >> 8 & 0x0F;
|
||||
var _loc7_:int = param2 >> 12 & 0x0F;
|
||||
var _loc5_:int = param2 >> 16 & 0x0F;
|
||||
var _loc4_:int = param2 >> 20 & 0x0F;
|
||||
var _loc18_:int = param3 & 0x0F;
|
||||
var _loc17_:int = param3 >> 4 & 0x0F;
|
||||
var _loc15_:int = param3 >> 8 & 0x0F;
|
||||
return [_loc10_,_loc11_,_loc13_,_loc12_,_loc16_,_loc14_,_loc8_,_loc9_,_loc6_,_loc7_,_loc5_,_loc4_,_loc18_,_loc17_,_loc15_];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
package pet
|
||||
{
|
||||
import com.sbi.client.SFEvent;
|
||||
import diamond.DiamondItem;
|
||||
import diamond.DiamondXtCommManager;
|
||||
import flash.utils.setTimeout;
|
||||
import loader.DefPacksDefHelper;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class PetXtCommManager
|
||||
{
|
||||
|
||||
public static var canLoadPetList:Boolean;
|
||||
|
||||
private static var _plCallback:Function;
|
||||
|
||||
private static var _pdCallback:Function;
|
||||
|
||||
private static var _psCallback:Function;
|
||||
|
||||
private static var _pcCallback:Function;
|
||||
|
||||
private static var _piCallback:Function;
|
||||
|
||||
private static var _pmCallback:Function;
|
||||
|
||||
public function PetXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
var _loc2_:Array = param1.obj;
|
||||
switch(_loc2_[0])
|
||||
{
|
||||
case "pl":
|
||||
onPetListResponse(_loc2_);
|
||||
break;
|
||||
case "pc":
|
||||
onPetCreateResponse(_loc2_);
|
||||
break;
|
||||
case "ps":
|
||||
onPetSwitchResponse(_loc2_);
|
||||
break;
|
||||
case "pi":
|
||||
onPetItemsResponse(_loc2_);
|
||||
break;
|
||||
case "pm":
|
||||
onPetMasteryResponse(_loc2_);
|
||||
break;
|
||||
case "pd":
|
||||
onPetDismissResponse(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendPetListRequest(param1:String, param2:Function = null) : void
|
||||
{
|
||||
_plCallback = param2;
|
||||
gMainFrame.server.setXtObject_Str("pl",[param1]);
|
||||
}
|
||||
|
||||
public static function sendPetCreateRequest(param1:int, param2:int, param3:uint, param4:int, param5:int, param6:Function = null, param7:Boolean = false) : void
|
||||
{
|
||||
_pcCallback = param6;
|
||||
gMainFrame.server.setXtObject_Str("pc",[param1,param2,param3,param4,param5,param7 ? "1" : "0"]);
|
||||
}
|
||||
|
||||
public static function sendPetShopBuyRequest(param1:int, param2:int, param3:int, param4:int, param5:uint, param6:int, param7:int, param8:Function = null, param9:Boolean = false) : void
|
||||
{
|
||||
_pcCallback = param8;
|
||||
gMainFrame.server.setXtObject_Str("pb",[param1,param2,GenericListXtCommManager.getAvailListUniqueId(),param3,param4,param5,param6,param7,param9 ? "1" : "0"]);
|
||||
}
|
||||
|
||||
public static function sendPetDismissRequest(param1:int, param2:Function = null) : void
|
||||
{
|
||||
_pdCallback = param2;
|
||||
gMainFrame.server.setXtObject_Str("pd",[param1]);
|
||||
}
|
||||
|
||||
public static function sendPetSwitchRequest(param1:int, param2:Function = null) : void
|
||||
{
|
||||
_psCallback = param2;
|
||||
gMainFrame.server.setXtObject_Str("ps",[param1]);
|
||||
}
|
||||
|
||||
public static function sendPetItemRequest(param1:int, param2:int, param3:int, param4:int, param5:Function) : void
|
||||
{
|
||||
_piCallback = param5;
|
||||
gMainFrame.server.setXtObject_Str("pi",[param1,param2,param3,param4]);
|
||||
}
|
||||
|
||||
public static function sendPetMasteryRequest(param1:int, param2:int, param3:Function = null) : void
|
||||
{
|
||||
_pmCallback = param3;
|
||||
gMainFrame.server.setXtObject_Str("pm",[param1,param2]);
|
||||
}
|
||||
|
||||
public static function petDefsResponse(param1:DefPacksDefHelper) : void
|
||||
{
|
||||
var _loc3_:Object = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc2_:Object = {};
|
||||
for each(var _loc5_:Object in param1.def)
|
||||
{
|
||||
_loc3_ = {
|
||||
"defId":int(_loc5_.id),
|
||||
"mediaRefId":int(_loc5_.mediaRefId),
|
||||
"type":int(_loc5_.type),
|
||||
"isGround":PetManager.isGround(_loc5_.type),
|
||||
"title":LocalizationManager.translateIdOnly(int(_loc5_.titleStrId)),
|
||||
"titleStrId":int(_loc5_.titleStrId),
|
||||
"isMember":_loc5_.isMember == "1",
|
||||
"cost":int(_loc5_.cost),
|
||||
"status":int(_loc5_.status),
|
||||
"isDiamond":false
|
||||
};
|
||||
_loc2_[_loc3_.defId] = _loc3_;
|
||||
}
|
||||
DefPacksDefHelper.mediaArray[1046] = null;
|
||||
var _loc4_:Array = PetManager.myPetList;
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc4_.length)
|
||||
{
|
||||
if(_loc4_[_loc6_].type == -1)
|
||||
{
|
||||
_loc4_[_loc6_].type = PetManager.petTypeForDefId(_loc4_[_loc6_].defId);
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
GenericListXtCommManager.requestGenericList(214,onDiamondPetListLoaded,_loc2_);
|
||||
}
|
||||
|
||||
private static function onDiamondPetListLoaded(param1:int, param2:Array, param3:Object) : void
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc6_:int = 0;
|
||||
var _loc4_:DiamondItem = null;
|
||||
if(DiamondXtCommManager.diamondDefsLoaded)
|
||||
{
|
||||
_loc5_ = 6;
|
||||
_loc7_ = int(param2[_loc5_++]);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc7_)
|
||||
{
|
||||
_loc4_ = DiamondXtCommManager.getDiamondItem(int(param2[_loc5_++]));
|
||||
if(_loc4_.isPet)
|
||||
{
|
||||
param3[_loc4_.refDefId].isDiamond = true;
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
PetManager.petDefs = param3;
|
||||
if(canLoadPetList)
|
||||
{
|
||||
sendPetListRequest(gMainFrame.server.userName);
|
||||
}
|
||||
canLoadPetList = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
setTimeout(onDiamondPetListLoaded,500,param1,param2,param3);
|
||||
}
|
||||
}
|
||||
|
||||
private static function onPetListResponse(param1:Array) : void
|
||||
{
|
||||
PetManager.onPetListResponse(param1,_plCallback);
|
||||
_plCallback = null;
|
||||
}
|
||||
|
||||
private static function onPetCreateResponse(param1:Array) : void
|
||||
{
|
||||
PetManager.onPetCreateResponse(param1,_pcCallback);
|
||||
_pcCallback = null;
|
||||
}
|
||||
|
||||
private static function onPetItemsResponse(param1:Array) : void
|
||||
{
|
||||
PetManager.onPetItemsResponse(param1,_piCallback);
|
||||
_piCallback = null;
|
||||
}
|
||||
|
||||
private static function onPetMasteryResponse(param1:Array) : void
|
||||
{
|
||||
PetManager.onPetMasteryResponse(param1,_pmCallback);
|
||||
_pmCallback = null;
|
||||
}
|
||||
|
||||
private static function onPetDismissResponse(param1:Array) : void
|
||||
{
|
||||
PetManager.onPetDismissResponse(param1,_pdCallback);
|
||||
_pdCallback = null;
|
||||
}
|
||||
|
||||
private static function onPetSwitchResponse(param1:Array) : void
|
||||
{
|
||||
PetManager.onPetSwitchResponse(param1,_psCallback);
|
||||
_psCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,321 @@
|
||||
package pet
|
||||
{
|
||||
import avatar.AvatarWorldView;
|
||||
import avatar.UserCommXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.geom.Matrix;
|
||||
import gui.GuiManager;
|
||||
|
||||
public class WorldPet extends PetBase
|
||||
{
|
||||
|
||||
public static const ANIM_IDLE:int = 0;
|
||||
|
||||
public static const ANIM_MOVE:int = 1;
|
||||
|
||||
public static const ANIM_IDLE_UP:int = 2;
|
||||
|
||||
public static const ANIM_MOVE_UP:int = 3;
|
||||
|
||||
public static const ANIM_CLICK:int = 4;
|
||||
|
||||
public static const ANIM_IDLE_WATER:int = 10;
|
||||
|
||||
public static const ANIM_IDLE_MUD:int = 20;
|
||||
|
||||
public static const ACTION_CLICK:int = 0;
|
||||
|
||||
public static const ACTION_SPARKLE:int = 1;
|
||||
|
||||
public static const PET_SPARKLE_TIME:int = 7200;
|
||||
|
||||
private var _parent:AvatarWorldView;
|
||||
|
||||
private var _mode:int;
|
||||
|
||||
private var _x:int;
|
||||
|
||||
private var _y:int;
|
||||
|
||||
private var _targetX:int;
|
||||
|
||||
private var _targetY:int;
|
||||
|
||||
private var _bNewTarget:Boolean;
|
||||
|
||||
private var _dirX:Number;
|
||||
|
||||
private var _dirY:Number;
|
||||
|
||||
private var _speed:Number;
|
||||
|
||||
private var _lastAnim:int;
|
||||
|
||||
private var _bFlip:Boolean;
|
||||
|
||||
private var _bBack:Boolean;
|
||||
|
||||
private var _bUpdateState:Boolean;
|
||||
|
||||
private var _parentLastX:Number;
|
||||
|
||||
private var _parentLastY:Number;
|
||||
|
||||
private var _bSpecialMove:Boolean;
|
||||
|
||||
private var _petLoaded:Boolean;
|
||||
|
||||
private var _sparkle:int;
|
||||
|
||||
private var _offsetX:int = 100;
|
||||
|
||||
private var _offsetY:int = -50;
|
||||
|
||||
private var _maxSpeed:Number = 1;
|
||||
|
||||
private var _accel:Number = 0.03;
|
||||
|
||||
private var _scale:Number = 1;
|
||||
|
||||
private var _minX:Number = -70;
|
||||
|
||||
private var _maxX:Number = 55;
|
||||
|
||||
private var _airPetYOffest:Number = -80;
|
||||
|
||||
private var _oceanPetXOffset:Number = 55;
|
||||
|
||||
private var _petLandLowXOffset:Number = 30;
|
||||
|
||||
public function WorldPet(param1:AvatarWorldView, param2:uint, param3:uint, param4:uint, param5:int = 0)
|
||||
{
|
||||
super(param2,param3,param4,onPetLoaded);
|
||||
_sparkle = param5;
|
||||
_parent = param1;
|
||||
_targetX = 0;
|
||||
_bNewTarget = true;
|
||||
_mode = 1;
|
||||
_lastAnim = -1;
|
||||
_bUpdateState = true;
|
||||
_bFlip = false;
|
||||
_bBack = false;
|
||||
_bSpecialMove = false;
|
||||
_parent.addChild(this);
|
||||
if(param1.userName.toLowerCase() == gMainFrame.server.userName.toLowerCase() && !GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
this.addEventListener("mouseDown",onClick,false,0,true);
|
||||
}
|
||||
if(_type == 0 || _type == 2 || _type == 4)
|
||||
{
|
||||
if(GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
_y = -5;
|
||||
GuiManager.actionMgr.grayOutPetDanceBtn(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_y = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GuiManager.actionMgr.grayOutPetDanceBtn(true);
|
||||
if(GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
_y = -5;
|
||||
}
|
||||
else
|
||||
{
|
||||
_y = _airPetYOffest;
|
||||
}
|
||||
}
|
||||
_parentLastX = _parent.x;
|
||||
_parentLastY = _parent.y;
|
||||
if(GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
_minX = 25;
|
||||
_maxX = -30;
|
||||
_x = _maxX;
|
||||
_parentLastX = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_type == 2)
|
||||
{
|
||||
_minX -= _oceanPetXOffset;
|
||||
_maxX += _oceanPetXOffset;
|
||||
}
|
||||
else if(_type == 0)
|
||||
{
|
||||
if(param1.avTypeId != 5)
|
||||
{
|
||||
_minX -= _petLandLowXOffset;
|
||||
}
|
||||
}
|
||||
_x = 0;
|
||||
}
|
||||
_targetX = 0;
|
||||
}
|
||||
|
||||
override public function destroy() : void
|
||||
{
|
||||
super.destroy();
|
||||
this.removeEventListener("mouseDown",onClick);
|
||||
}
|
||||
|
||||
public function heartbeat(param1:int) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:Matrix = null;
|
||||
var _loc2_:int = 0;
|
||||
if(_content)
|
||||
{
|
||||
_loc4_ = _parent.isPetMovingTest() ? 1 : 0;
|
||||
if(GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
if(_parentLastX != _parent.x)
|
||||
{
|
||||
if(_parent.x > _parentLastX)
|
||||
{
|
||||
if(!_bFlip)
|
||||
{
|
||||
_parent.flipSplash(true);
|
||||
_bFlip = true;
|
||||
_x = _minX;
|
||||
}
|
||||
}
|
||||
else if(_bFlip)
|
||||
{
|
||||
_parent.flipSplash(false);
|
||||
_bFlip = false;
|
||||
_x = _maxX;
|
||||
}
|
||||
_parentLastX = _parent.x;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_targetX == 0)
|
||||
{
|
||||
_targetX = _parent.hFlip ? _minX : _maxX;
|
||||
}
|
||||
if(_parentLastX != _parent.x)
|
||||
{
|
||||
_bFlip = _parent.x > _parentLastX ? true : false;
|
||||
if(Math.abs(_parentLastX - _parent.x) > 13)
|
||||
{
|
||||
_targetX = _bFlip ? _minX : _maxX;
|
||||
}
|
||||
_parentLastX = _parent.x;
|
||||
}
|
||||
if(_parentLastY != _parent.y)
|
||||
{
|
||||
_bBack = _parent.y < _parentLastY - 10 ? true : false;
|
||||
_parentLastY = _parent.y;
|
||||
}
|
||||
if(_x > _targetX)
|
||||
{
|
||||
_x -= 10;
|
||||
if(_x <= _targetX)
|
||||
{
|
||||
_x = _targetX;
|
||||
}
|
||||
_bFlip = _x == _targetX ? true : false;
|
||||
}
|
||||
if(_x < _targetX)
|
||||
{
|
||||
_x += 10;
|
||||
if(_x > _targetX)
|
||||
{
|
||||
_x = _targetX;
|
||||
}
|
||||
_bFlip = _x == _targetX ? false : true;
|
||||
}
|
||||
if(_x != _targetX)
|
||||
{
|
||||
_loc4_ = 1;
|
||||
}
|
||||
}
|
||||
if(_bUpdateState)
|
||||
{
|
||||
PetManager.setPetState(_content,_lBits,_uBits,_eBits);
|
||||
_bUpdateState = false;
|
||||
}
|
||||
_loc3_ = _parent.inSplashVolume() ? 10 : 0;
|
||||
if(_loc3_ && _parent.splashLiquid == "mud")
|
||||
{
|
||||
_loc3_ = 20;
|
||||
}
|
||||
if(_parent.splashLiquid != "mud" && _parent.splashLiquid != "water")
|
||||
{
|
||||
_loc3_ = 0;
|
||||
}
|
||||
_loc5_ = _content.transform.matrix;
|
||||
_loc5_.identity();
|
||||
_loc5_.scale(_bFlip ? -_scale : _scale,_scale);
|
||||
_loc5_.translate(_x,_y - param1);
|
||||
_content.transform.matrix = _loc5_;
|
||||
_loc2_ = _loc3_ + _loc4_;
|
||||
if(_bBack)
|
||||
{
|
||||
_loc2_ += 2;
|
||||
}
|
||||
if(_lastAnim != _loc2_)
|
||||
{
|
||||
_lastAnim = _loc2_;
|
||||
_content.pet.setAnim(_loc2_);
|
||||
}
|
||||
if(_bSpecialMove)
|
||||
{
|
||||
_bSpecialMove = false;
|
||||
if(!_loc4_)
|
||||
{
|
||||
_content.pet.setAnim(4 + _loc3_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setState(param1:Array) : void
|
||||
{
|
||||
_lBits = param1[0];
|
||||
_uBits = param1[1];
|
||||
_eBits = param1[2];
|
||||
_bUpdateState = true;
|
||||
}
|
||||
|
||||
public function setAction(param1:int, param2:int = 0) : void
|
||||
{
|
||||
switch(param1)
|
||||
{
|
||||
case 0:
|
||||
onClick();
|
||||
break;
|
||||
case 1:
|
||||
setSparkle(param2);
|
||||
}
|
||||
}
|
||||
|
||||
public function onClick(param1:MouseEvent = null) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
param1.stopPropagation();
|
||||
UserCommXtCommManager.sendPetAction(0);
|
||||
}
|
||||
_bSpecialMove = true;
|
||||
}
|
||||
|
||||
private function onPetLoaded(param1:MovieClip) : void
|
||||
{
|
||||
if(GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
_content.pet.scaleX = _content.pet.scaleY = 2;
|
||||
}
|
||||
_content.pet.setSparkle(_sparkle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user