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(idx:int, lBits:uint, uBits:uint, eBits:uint, type:int, name:String, onPetLoadedCallback:Function)
|
||||
{
|
||||
this._onPetLoadedCallback = onPetLoadedCallback;
|
||||
super(lBits,uBits,eBits,this.onPetLoaded);
|
||||
this.idx = idx;
|
||||
this._petName = name;
|
||||
}
|
||||
|
||||
public function get petName() : String
|
||||
{
|
||||
return LocalizationManager.translatePetName(this._petName);
|
||||
}
|
||||
|
||||
private function onPetLoaded(content:MovieClip) : void
|
||||
{
|
||||
if(this._onPetLoadedCallback != null)
|
||||
{
|
||||
this._onPetLoadedCallback(content,this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
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 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(lBits:uint, uBits:uint, eBits:uint, onPetLoadedCallback:Function)
|
||||
{
|
||||
super();
|
||||
this._lBits = lBits;
|
||||
this._uBits = uBits;
|
||||
this._eBits = eBits;
|
||||
this._onPetLoadedCallback = onPetLoadedCallback;
|
||||
this._defId = lBits & 0xFF;
|
||||
this._type = PetManager.petTypeForDefId(this._defId);
|
||||
this._mediaHelper = new MediaHelper();
|
||||
this._mediaHelper.init(this.mediaIdForDefId(this._defId),this.onMediaLoaded,true);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function isGround() : Boolean
|
||||
{
|
||||
return PetManager.isGround(this._type);
|
||||
}
|
||||
|
||||
public function getType() : int
|
||||
{
|
||||
return this._type;
|
||||
}
|
||||
|
||||
public function getDefID() : int
|
||||
{
|
||||
return this._defId;
|
||||
}
|
||||
|
||||
public function canGoInOcean() : Boolean
|
||||
{
|
||||
if(this._type == PetManager.TYPE_OCEAN_LOW || this._type == PetManager.TYPE_OCEAN_HIGH || this._type == PetManager.TYPE_AMPHIB_LOW || this._type == PetManager.TYPE_AMPHIB_HIGH)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function canGoOnLand() : Boolean
|
||||
{
|
||||
if(this._type == PetManager.TYPE_LAND_LOW || this._type == PetManager.TYPE_LAND_HIGH || this._type == PetManager.TYPE_AMPHIB_LOW || this._type == PetManager.TYPE_AMPHIB_HIGH)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getLBits() : uint
|
||||
{
|
||||
return this._lBits;
|
||||
}
|
||||
|
||||
public function getUBits() : uint
|
||||
{
|
||||
return this._uBits;
|
||||
}
|
||||
|
||||
public function getEBits() : uint
|
||||
{
|
||||
return this._eBits;
|
||||
}
|
||||
|
||||
public function getContent() : MovieClip
|
||||
{
|
||||
return this._content;
|
||||
}
|
||||
|
||||
public function colorMyItem(catId:int, mc:MovieClip, r1:int, g1:int, b1:int, r2:int, g2:int, b2:int) : void
|
||||
{
|
||||
if(Boolean(this._content))
|
||||
{
|
||||
this._content.colorMe(catId,mc,r1,g1,b1,r2,g2,b2);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateAllBits(lBits:uint, uBits:uint, eBits:uint) : void
|
||||
{
|
||||
if(Boolean(this._content))
|
||||
{
|
||||
this._lBits = lBits;
|
||||
this._uBits = uBits;
|
||||
this._eBits = eBits;
|
||||
PetManager.setPetState(this._content,this._lBits,this._uBits,this._eBits);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateUBits(upperBits:uint) : void
|
||||
{
|
||||
this._uBits = upperBits;
|
||||
PetManager.setPetState(this._content,this._lBits,this._uBits,this._eBits);
|
||||
}
|
||||
|
||||
protected function setSparkle(sparkleId:int) : void
|
||||
{
|
||||
if(Boolean(this._content))
|
||||
{
|
||||
this._content.pet.setSparkle(sparkleId);
|
||||
}
|
||||
}
|
||||
|
||||
private function onMediaLoaded(img:MovieClip) : void
|
||||
{
|
||||
if(Boolean(img))
|
||||
{
|
||||
this._content = img;
|
||||
this.addChild(this._content);
|
||||
this._mediaHelper.destroy();
|
||||
delete this._content.mediaHelper;
|
||||
delete this._content.passback;
|
||||
PetManager.setPetState(this._content,this._lBits,this._uBits,this._eBits);
|
||||
if(this._onPetLoadedCallback != null)
|
||||
{
|
||||
this._onPetLoadedCallback(this._content);
|
||||
}
|
||||
this._content.pet.setAnim(0);
|
||||
}
|
||||
}
|
||||
|
||||
private function mediaIdForDefId(defId:int) : int
|
||||
{
|
||||
var petDef:Object = PetManager.getPetDef(defId);
|
||||
if(Boolean(petDef))
|
||||
{
|
||||
return petDef.mediaRefId;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,860 @@
|
||||
package pet
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import avatar.AvatarInfo;
|
||||
import avatar.AvatarManager;
|
||||
import avatar.AvatarWorldView;
|
||||
import avatar.UserCommXtCommManager;
|
||||
import avatar.UserInfo;
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import den.DenXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import gui.PartyManager;
|
||||
import gui.PetFinder;
|
||||
import gui.PetMastery;
|
||||
import item.Item;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class PetManager
|
||||
{
|
||||
|
||||
private static var _petDefs:Object;
|
||||
|
||||
private static var _myPetList:Array;
|
||||
|
||||
private static var _myActivePetInvId:int;
|
||||
|
||||
private static var _petFinderCloseCallback:Function;
|
||||
|
||||
private static var _petFinder:PetFinder;
|
||||
|
||||
private static var _petMasteryMgr:PetMastery;
|
||||
|
||||
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;
|
||||
|
||||
public function PetManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
_myPetList = [];
|
||||
}
|
||||
|
||||
public static function set petDefs(o:Object) : void
|
||||
{
|
||||
_petDefs = o;
|
||||
}
|
||||
|
||||
public static function relocalizePetDefs() : void
|
||||
{
|
||||
var p:Object = null;
|
||||
for each(p in _petDefs)
|
||||
{
|
||||
p.title = LocalizationManager.translateIdOnly(p.titleStrId);
|
||||
}
|
||||
}
|
||||
|
||||
public static function openPetFinder(petName:String = "", closeCallback:Function = null, isFromRedemption:Boolean = false, petData:Array = null) : void
|
||||
{
|
||||
if(Boolean(_petFinder))
|
||||
{
|
||||
_petFinder.destroy();
|
||||
_petFinder = null;
|
||||
}
|
||||
_petFinder = new PetFinder();
|
||||
if(petName == "")
|
||||
{
|
||||
_petFinder.init(-1,closeCallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
_petFinder.init(petDefIdForName(petName),closeCallback,isFromRedemption,petData);
|
||||
}
|
||||
}
|
||||
|
||||
public static function checkAndOpenMasteryPopup(hasAchieved:Boolean) : void
|
||||
{
|
||||
if(Boolean(myActivePet) && Boolean(myActivePet.masteryCounter >= MASTERY_ACHIV_MIN_COUNT) && hasAchieved)
|
||||
{
|
||||
if(!_petMasteryMgr)
|
||||
{
|
||||
_petMasteryMgr = new PetMastery();
|
||||
_petMasteryMgr.init();
|
||||
}
|
||||
_petMasteryMgr.displayMasteryPopup();
|
||||
}
|
||||
}
|
||||
|
||||
public static function onPetListResponse(data:Array, callback:Function) : void
|
||||
{
|
||||
var petsData:Array = null;
|
||||
var userName:String = null;
|
||||
var numPets:int = 0;
|
||||
var pd:Object = null;
|
||||
var idxToUpdate:int = 0;
|
||||
var i:int = 0;
|
||||
var j:int = 2;
|
||||
var status:String = data[j++];
|
||||
if(status == "1")
|
||||
{
|
||||
userName = data[j++];
|
||||
numPets = int(data[j++]);
|
||||
petsData = [];
|
||||
idxToUpdate = -1;
|
||||
for(i = 0; i < numPets; i++)
|
||||
{
|
||||
pd = {
|
||||
"idx":int(data[j++]),
|
||||
"name":data[j++],
|
||||
"isGround":isGround(data[j++]),
|
||||
"lBits":uint(data[j++]),
|
||||
"uBits":uint(data[j++]),
|
||||
"eBits":uint(data[j++]),
|
||||
"masteryCounter":uint(data[j++]),
|
||||
"isSparkling":false
|
||||
};
|
||||
pd.defId = getDefIdFromLBits(pd.lBits);
|
||||
pd.type = petTypeForDefId(pd.defId);
|
||||
petsData.push(pd);
|
||||
}
|
||||
petsData.sortOn("idx",Array.NUMERIC);
|
||||
if(userName == gMainFrame.userInfo.myUserName)
|
||||
{
|
||||
_myPetList = petsData;
|
||||
}
|
||||
}
|
||||
if(callback != null)
|
||||
{
|
||||
callback(petsData,status == "-1");
|
||||
}
|
||||
}
|
||||
|
||||
public static function isGround(type:int) : Boolean
|
||||
{
|
||||
return type == PetBase.TYPE_LAND_GROUND || type == PetBase.TYPE_OCEAN_GROUND || type == PetBase.TYPE_AMPHIB_GROUND;
|
||||
}
|
||||
|
||||
public static function onPetCreateResponse(data:Array, callback:Function) : void
|
||||
{
|
||||
var prevBalance:int = 0;
|
||||
var newBalance:int = 0;
|
||||
var currencyType:int = 0;
|
||||
var invId:int = 0;
|
||||
var lBits:uint = 0;
|
||||
var uBits:uint = 0;
|
||||
var eBits:uint = 0;
|
||||
var petName:String = null;
|
||||
var defId:int = 0;
|
||||
var def:Object = null;
|
||||
var petObj:Object = null;
|
||||
var j:int = 2;
|
||||
if(data[j++] == "1")
|
||||
{
|
||||
newBalance = int(data[j++]);
|
||||
currencyType = int(data[j++]);
|
||||
switch(currencyType)
|
||||
{
|
||||
case Item.GEM_CURRENCY:
|
||||
prevBalance = int(gMainFrame.clientInfo.gemCount);
|
||||
if(prevBalance != newBalance)
|
||||
{
|
||||
gMainFrame.clientInfo.gemCount = newBalance;
|
||||
}
|
||||
break;
|
||||
case Item.TICKET_CURRENCY:
|
||||
prevBalance = int(gMainFrame.clientInfo.ticketCount);
|
||||
if(prevBalance != newBalance)
|
||||
{
|
||||
gMainFrame.clientInfo.ticketCount = newBalance;
|
||||
}
|
||||
break;
|
||||
case Item.ORB_CURRENCY:
|
||||
prevBalance = int(gMainFrame.clientInfo.orbCount);
|
||||
if(prevBalance != newBalance)
|
||||
{
|
||||
gMainFrame.clientInfo.orbCount = newBalance;
|
||||
}
|
||||
break;
|
||||
case Item.DIAMOND_CURRENCY:
|
||||
prevBalance = int(gMainFrame.clientInfo.diamondCount);
|
||||
if(prevBalance != newBalance)
|
||||
{
|
||||
gMainFrame.clientInfo.diamondCount = newBalance;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error("ItemManager: Received unknown currencyType: " + currencyType);
|
||||
}
|
||||
if(prevBalance != newBalance)
|
||||
{
|
||||
AJAudio.playShopCachingSound();
|
||||
}
|
||||
invId = int(data[j++]);
|
||||
lBits = uint(data[j++]);
|
||||
uBits = uint(data[j++]);
|
||||
eBits = uint(data[j++]);
|
||||
petName = data[j++];
|
||||
defId = getDefIdFromLBits(lBits);
|
||||
def = getPetDef(defId);
|
||||
if(Boolean(def))
|
||||
{
|
||||
petObj = {
|
||||
"idx":invId,
|
||||
"name":petName,
|
||||
"defId":defId,
|
||||
"type":def.type,
|
||||
"lBits":lBits,
|
||||
"uBits":uBits,
|
||||
"eBits":eBits,
|
||||
"isSparkling":false
|
||||
};
|
||||
petObj.masteryCounter = 0;
|
||||
_myPetList.push(petObj);
|
||||
if(!def.isMember || Boolean(gMainFrame.userInfo.isMember))
|
||||
{
|
||||
AvatarManager.playerAvatarWorldView.setActivePet(lBits,uBits,eBits,petName);
|
||||
myActivePetInvId = invId;
|
||||
}
|
||||
DenXtCommManager.addPetToDen(petObj);
|
||||
AvatarManager.setPetAction(AvatarManager.playerSfsUserId,WorldPet.ACTION_SPARKLE,0);
|
||||
if(callback != null)
|
||||
{
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14809));
|
||||
}
|
||||
}
|
||||
|
||||
public static function onPetSwitchResponse(data:Array, callback:Function) : void
|
||||
{
|
||||
var awv:AvatarWorldView = null;
|
||||
var sfsUserId:int = 0;
|
||||
var ui:UserInfo = null;
|
||||
var avInfo:AvatarInfo = null;
|
||||
var myPet:Object = null;
|
||||
var hasFound:Boolean = false;
|
||||
var o:Object = null;
|
||||
var lBits:int = 0;
|
||||
var uBits:int = 0;
|
||||
var eBits:int = 0;
|
||||
var petName:String = null;
|
||||
var currPet:Object = null;
|
||||
var ai:AvatarInfo = null;
|
||||
var j:int = 2;
|
||||
var status:Boolean = data[j++] == "1";
|
||||
if(status)
|
||||
{
|
||||
sfsUserId = int(data[j++]);
|
||||
awv = AvatarManager.getAvatarWorldViewBySfsUserId(sfsUserId);
|
||||
if(sfsUserId == gMainFrame.server.userId)
|
||||
{
|
||||
myActivePetInvId = int(data[j++]);
|
||||
if(Boolean(awv))
|
||||
{
|
||||
if(myActivePetInvId != 0)
|
||||
{
|
||||
for each(o in _myPetList)
|
||||
{
|
||||
if(o.idx == myActivePetInvId)
|
||||
{
|
||||
awv.setActivePet(o.lBits,o.uBits,o.eBits,o.name);
|
||||
hasFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
awv.setActivePet(0,0,0,"");
|
||||
}
|
||||
ui = gMainFrame.userInfo.getUserInfoByUserName(awv.userName);
|
||||
for each(avInfo in ui.avList)
|
||||
{
|
||||
if(avInfo.perUserAvId == awv.perUserAvId)
|
||||
{
|
||||
if(AvatarManager.roomEnviroType == Utility.ENVIRO_LAND)
|
||||
{
|
||||
avInfo.landPetInvId = myActivePetInvId;
|
||||
}
|
||||
else
|
||||
{
|
||||
avInfo.oceanPetInvId = myActivePetInvId;
|
||||
}
|
||||
gMainFrame.userInfo.setUserInfoByUserName(awv.userName,ui);
|
||||
break;
|
||||
}
|
||||
}
|
||||
AvatarManager.setPetAction(AvatarManager.playerSfsUserId,WorldPet.ACTION_SPARKLE,0);
|
||||
myPet = myActivePet;
|
||||
if(Boolean(myPet))
|
||||
{
|
||||
awv.setActivePet(myPet.lBits,myPet.uBits,myPet.eBits,myPet.name);
|
||||
myPet.isSparkling = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lBits = int(data[j++]);
|
||||
uBits = int(data[j++]);
|
||||
eBits = int(data[j++]);
|
||||
petName = data[j++];
|
||||
if(Boolean(awv))
|
||||
{
|
||||
awv.setActivePet(lBits,uBits,uBits,petName);
|
||||
}
|
||||
currPet = null;
|
||||
if(lBits != 0)
|
||||
{
|
||||
currPet = {
|
||||
"name":petName,
|
||||
"lBits":lBits,
|
||||
"uBits":uBits,
|
||||
"eBits":eBits
|
||||
};
|
||||
currPet.defId = PetManager.getDefIdFromLBits(currPet.lBits);
|
||||
currPet.type = PetManager.petTypeForDefId(currPet.defId);
|
||||
currPet.isGround = PetManager.isGround(currPet.type);
|
||||
}
|
||||
ai = gMainFrame.userInfo.getAvatarInfoByUserName(awv.userName);
|
||||
if(Boolean(ai))
|
||||
{
|
||||
ai.currPet = currPet;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14810));
|
||||
}
|
||||
if(callback != null)
|
||||
{
|
||||
callback(status);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onPetItemsResponse(data:Array, callback:Function) : void
|
||||
{
|
||||
var gemBalance:int = 0;
|
||||
var myActivePet:Object = null;
|
||||
var invId:int = 0;
|
||||
var lBits:int = 0;
|
||||
var uBits:int = 0;
|
||||
var eBits:int = 0;
|
||||
var j:int = 2;
|
||||
var status:Boolean = data[j++] == "1";
|
||||
if(status)
|
||||
{
|
||||
gemBalance = int(data[j++]);
|
||||
gMainFrame.clientInfo.gemCount = gemBalance;
|
||||
AJAudio.playShopCachingSound();
|
||||
myActivePet = myActivePet;
|
||||
if(myActivePet == null)
|
||||
{
|
||||
trace("ERROR: myActivePet is null");
|
||||
return;
|
||||
}
|
||||
invId = int(data[j++]);
|
||||
if(myActivePet.idx != invId)
|
||||
{
|
||||
trace("ERROR: Invalid pet invId");
|
||||
return;
|
||||
}
|
||||
lBits = int(data[j++]);
|
||||
uBits = int(data[j++]);
|
||||
eBits = int(data[j++]);
|
||||
myActivePet.lBits = lBits;
|
||||
myActivePet.uBits = uBits;
|
||||
myActivePet.eBits = eBits;
|
||||
AvatarManager.playerAvatarWorldView.setActivePet(lBits,uBits,eBits,myActivePetName);
|
||||
myActivePetInvId = invId;
|
||||
DenXtCommManager.reloadPetInDen(invId,lBits,uBits,eBits);
|
||||
}
|
||||
if(callback != null)
|
||||
{
|
||||
callback(status);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onPetMasteryResponse(data:Array, callback:Function) : void
|
||||
{
|
||||
var invId:int = 0;
|
||||
var i:int = 0;
|
||||
var lBits:int = 0;
|
||||
var uBits:int = 0;
|
||||
var eBits:int = 0;
|
||||
var j:int = 2;
|
||||
var status:Boolean = data[j++] == "1";
|
||||
if(status)
|
||||
{
|
||||
invId = int(data[j++]);
|
||||
for(i = 0; i < _myPetList.length; i++)
|
||||
{
|
||||
if(_myPetList[i].idx == invId)
|
||||
{
|
||||
lBits = int(data[j++]);
|
||||
uBits = int(data[j++]);
|
||||
eBits = int(data[j++]);
|
||||
_myPetList[i].lBits = lBits;
|
||||
_myPetList[i].uBits = uBits;
|
||||
_myPetList[i].eBits = eBits;
|
||||
DenXtCommManager.reloadPetInDen(invId,lBits,uBits,eBits);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(callback != null)
|
||||
{
|
||||
callback(status);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onPetDismissResponse(data:Array, callback:Function) : void
|
||||
{
|
||||
var isFound:Boolean = false;
|
||||
var wasActivePet:Boolean = false;
|
||||
var i:int = 0;
|
||||
var status:Boolean = data[2] == "1";
|
||||
var invIdx:int = int(data[3]);
|
||||
if(status)
|
||||
{
|
||||
for(i = 0; i < _myPetList.length; i++)
|
||||
{
|
||||
if(_myPetList[i].idx == invIdx)
|
||||
{
|
||||
if(_myActivePetInvId == _myPetList[i].idx)
|
||||
{
|
||||
_myActivePetInvId = 0;
|
||||
AvatarManager.playerAvatarWorldView.setActivePet(0,0,0,"");
|
||||
wasActivePet = true;
|
||||
AvatarManager.setPetAction(AvatarManager.playerSfsUserId,WorldPet.ACTION_SPARKLE,0);
|
||||
}
|
||||
_myPetList.splice(i,1);
|
||||
DenXtCommManager.removePetFromDen(invIdx);
|
||||
isFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14786));
|
||||
}
|
||||
if(callback != null)
|
||||
{
|
||||
callback(status,isFound,wasActivePet);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getPetSprite(lBits:uint, uBits:uint, eBits:uint, type:int, onLoadedCallback:Function = null) : Sprite
|
||||
{
|
||||
return Sprite(new PetBase(lBits,uBits,eBits,onLoadedCallback));
|
||||
}
|
||||
|
||||
public static function getGuiPet(idx:int, lBits:uint, uBits:uint, eBits:uint, type:int, name:String, onLoadedCallback:Function = null) : GuiPet
|
||||
{
|
||||
return new GuiPet(idx,lBits,uBits,eBits,type,name,onLoadedCallback);
|
||||
}
|
||||
|
||||
public static function get myPetList() : Array
|
||||
{
|
||||
return _myPetList;
|
||||
}
|
||||
|
||||
public static function get myActivePetName() : String
|
||||
{
|
||||
var myPet:Object = getMyPetByInvId(_myActivePetInvId);
|
||||
if(Boolean(myPet))
|
||||
{
|
||||
return myPet.name;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function set myActivePetInvId(value:int) : void
|
||||
{
|
||||
_myActivePetInvId = value;
|
||||
}
|
||||
|
||||
public static function addToActivePetMastery(amount:int) : void
|
||||
{
|
||||
myActivePet.masteryCounter += amount;
|
||||
}
|
||||
|
||||
public static function get myActivePetInvId() : int
|
||||
{
|
||||
return _myActivePetInvId;
|
||||
}
|
||||
|
||||
public static function getMyPetByInvId(invId:int) : Object
|
||||
{
|
||||
var o:Object = null;
|
||||
for each(o in _myPetList)
|
||||
{
|
||||
if(o.idx == invId)
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function get myActivePet() : Object
|
||||
{
|
||||
var o:Object = null;
|
||||
for each(o in _myPetList)
|
||||
{
|
||||
if(o.idx == _myActivePetInvId)
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function petTypeForDefId(defId:int) : int
|
||||
{
|
||||
if(Boolean(_petDefs) && Boolean(_petDefs[defId]))
|
||||
{
|
||||
return _petDefs[defId].type;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static function getPetDef(defId:int) : Object
|
||||
{
|
||||
if(Boolean(_petDefs))
|
||||
{
|
||||
return _petDefs[defId];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function petForPetDefId(defId:int) : Object
|
||||
{
|
||||
var o:Object = null;
|
||||
for each(o in _myPetList)
|
||||
{
|
||||
if(o.defId == defId)
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getEnviroTypeByPetType(type:int, avatarEnviroTypeFlag:int = 0) : int
|
||||
{
|
||||
if(type == TYPE_LAND_LOW)
|
||||
{
|
||||
return Utility.ENVIRO_LAND;
|
||||
}
|
||||
if(type == TYPE_LAND_HIGH)
|
||||
{
|
||||
return Utility.isAir(avatarEnviroTypeFlag) ? Utility.ENVIRO_AIR : Utility.ENVIRO_LAND;
|
||||
}
|
||||
if(type == TYPE_OCEAN_HIGH || type == TYPE_OCEAN_LOW)
|
||||
{
|
||||
return Utility.ENVIRO_OCEAN;
|
||||
}
|
||||
if(type == TYPE_AMPHIB_LOW || type == TYPE_AMPHIB_HIGH)
|
||||
{
|
||||
return AvatarManager.roomEnviroType;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static function setPetState(petMC:MovieClip, lBits:uint, uBits:uint, eBits:uint) : void
|
||||
{
|
||||
var test:int = lBits & 0xFF;
|
||||
if(test == 15)
|
||||
{
|
||||
petMC.pet.setState(lBits,uBits,eBits,AvatarManager.roomEnviroType);
|
||||
}
|
||||
else
|
||||
{
|
||||
petMC.pet.setState(lBits,uBits);
|
||||
}
|
||||
}
|
||||
|
||||
public static function petDefIdForName(petName:String) : int
|
||||
{
|
||||
switch(petName)
|
||||
{
|
||||
case "frog":
|
||||
return PetBase.DEF_ID_FROG;
|
||||
case "kitten":
|
||||
return PetBase.DEF_ID_CAT;
|
||||
case "puppy":
|
||||
return PetBase.DEF_ID_DOG;
|
||||
case "ducky":
|
||||
return PetBase.DEF_ID_DUCK;
|
||||
case "butterfly":
|
||||
return PetBase.DEF_ID_BFLY;
|
||||
case "hamster":
|
||||
return PetBase.DEF_ID_HAMS;
|
||||
case "bat":
|
||||
return PetBase.DEF_ID_BAT;
|
||||
case "seahorse":
|
||||
return PetBase.DEF_ID_SEAHORSE;
|
||||
case "anglerfish":
|
||||
return PetBase.DEF_ID_ANGLER;
|
||||
case "reindeer":
|
||||
return PetBase.DEF_ID_REINDEER;
|
||||
case "snake":
|
||||
return PetBase.DEF_ID_SNAKE;
|
||||
case "jellyfish":
|
||||
return PetBase.DEF_ID_JELLYFISH;
|
||||
case "bunny":
|
||||
return PetBase.DEF_ID_BUNNY;
|
||||
case "hummingbird":
|
||||
return PetBase.DEF_ID_HUMMINGBIRD;
|
||||
case "turtle":
|
||||
return PetBase.DEF_ID_TURTLE;
|
||||
case "monkey":
|
||||
return PetBase.DEF_ID_MONKEY;
|
||||
case "tarantula":
|
||||
return PetBase.DEF_ID_TARANTUAL;
|
||||
case "fox":
|
||||
return PetBase.DEF_ID_FOX;
|
||||
case "owl":
|
||||
return PetBase.DEF_ID_OWL;
|
||||
case "tiger":
|
||||
return PetBase.DEF_ID_TIGER;
|
||||
case "arcticwolfpup":
|
||||
return PetBase.DEF_ID_ARCTIC_WOLF;
|
||||
case "raccoon":
|
||||
return PetBase.DEF_ID_RACCOON;
|
||||
case "joey":
|
||||
return PetBase.DEF_ID_JOEY;
|
||||
case "eaglet":
|
||||
return PetBase.DEF_ID_EAGLET;
|
||||
case "cheetah":
|
||||
return PetBase.DEF_ID_CHEETAH;
|
||||
case "rhino":
|
||||
return PetBase.DEF_ID_RHINO;
|
||||
case "giraffe":
|
||||
return PetBase.DEF_ID_GIRAFFE;
|
||||
case "sugarglider":
|
||||
return PetBase.DEF_ID_SUGAR_GLIDER;
|
||||
case "lionCub":
|
||||
return PetBase.DEF_ID_LION_CUB;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static function petNameForDefId(defId:int) : String
|
||||
{
|
||||
switch(defId)
|
||||
{
|
||||
case PetBase.DEF_ID_FROG:
|
||||
return "frog";
|
||||
case PetBase.DEF_ID_CAT:
|
||||
return "kitten";
|
||||
case PetBase.DEF_ID_DOG:
|
||||
return "puppy";
|
||||
case PetBase.DEF_ID_DUCK:
|
||||
return "ducky";
|
||||
case PetBase.DEF_ID_BFLY:
|
||||
return "butterfly";
|
||||
case PetBase.DEF_ID_HAMS:
|
||||
return "hamster";
|
||||
case PetBase.DEF_ID_BAT:
|
||||
return "bat";
|
||||
case PetBase.DEF_ID_SEAHORSE:
|
||||
return "seahorse";
|
||||
case PetBase.DEF_ID_ANGLER:
|
||||
return "anglerfish";
|
||||
case PetBase.DEF_ID_REINDEER:
|
||||
return "reindeer";
|
||||
case PetBase.DEF_ID_SNAKE:
|
||||
return "snake";
|
||||
case PetBase.DEF_ID_JELLYFISH:
|
||||
return "jellyfish";
|
||||
case PetBase.DEF_ID_BUNNY:
|
||||
return "bunny";
|
||||
case PetBase.DEF_ID_HUMMINGBIRD:
|
||||
return "hummingbird";
|
||||
case PetBase.DEF_ID_TURTLE:
|
||||
return "turtle";
|
||||
case PetBase.DEF_ID_MONKEY:
|
||||
return "monkey";
|
||||
case PetBase.DEF_ID_TARANTUAL:
|
||||
return "tarantula";
|
||||
case PetBase.DEF_ID_FOX:
|
||||
return "fox";
|
||||
case PetBase.DEF_ID_OWL:
|
||||
return "owl";
|
||||
case PetBase.DEF_ID_TIGER:
|
||||
return "tiger";
|
||||
case PetBase.DEF_ID_ARCTIC_WOLF:
|
||||
return "arcticwolfpup";
|
||||
case PetBase.DEF_ID_RACCOON:
|
||||
return "raccoon";
|
||||
case PetBase.DEF_ID_JOEY:
|
||||
return "joey";
|
||||
case PetBase.DEF_ID_EAGLET:
|
||||
return "eaglet";
|
||||
case PetBase.DEF_ID_CHEETAH:
|
||||
return "cheetah";
|
||||
case PetBase.DEF_ID_RHINO:
|
||||
return "rhino";
|
||||
case PetBase.DEF_ID_GIRAFFE:
|
||||
return "giraffe";
|
||||
case PetBase.DEF_ID_SUGAR_GLIDER:
|
||||
return "sugarglider";
|
||||
case PetBase.DEF_ID_LION_CUB:
|
||||
return "lionCub";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static function getDefIdFromLBits(lBits:int) : int
|
||||
{
|
||||
return lBits & 0xFF;
|
||||
}
|
||||
|
||||
public static function sendPetSparkle(sparkle:int) : void
|
||||
{
|
||||
UserCommXtCommManager.sendPetAction(WorldPet.ACTION_SPARKLE,sparkle);
|
||||
}
|
||||
|
||||
public static function getPetInventoryMax() : int
|
||||
{
|
||||
return gMainFrame.userInfo.userVarCache.getUserVarValueById(AchievementXtCommManager.UV_PET_INVENTORY_MAX);
|
||||
}
|
||||
|
||||
public static function isPetAvailable(petDefId:int) : Boolean
|
||||
{
|
||||
if((gMainFrame.userInfo.userVarCache.getUserVarValueById(AchievementXtCommManager.UV_PET_VIEWABLE_FLAG) & 1 << petDefId - 1) != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canCurrAvatarUsePet(avatarEnviroTypeFlag:int, petType:int) : Boolean
|
||||
{
|
||||
var ignoreByEnviroTypeFlag:Boolean = false;
|
||||
var currPartyDef:Object = null;
|
||||
if(gMainFrame.clientInfo.roomType == Utility.ROOMTYPE_PARTY)
|
||||
{
|
||||
currPartyDef = PartyManager.getPartyDef(gMainFrame.clientInfo.secondaryDefId);
|
||||
if(currPartyDef != null)
|
||||
{
|
||||
if(currPartyDef.restrictions == PartyManager.RESTRICTIONS_BEYOURPET)
|
||||
{
|
||||
ignoreByEnviroTypeFlag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return canBeUsedInEnviroType(petType,AvatarManager.roomEnviroType) && (ignoreByEnviroTypeFlag ? true : canBeUsedByEnviroTypeFlag(petType,avatarEnviroTypeFlag));
|
||||
}
|
||||
|
||||
private static function canBeUsedInEnviroType(petType:int, enviroType:int) : Boolean
|
||||
{
|
||||
if(petType == TYPE_LAND_LOW || petType == TYPE_LAND_HIGH)
|
||||
{
|
||||
return enviroType == Utility.ENVIRO_LAND;
|
||||
}
|
||||
if(petType == TYPE_OCEAN_LOW || petType == TYPE_OCEAN_HIGH)
|
||||
{
|
||||
return enviroType == Utility.ENVIRO_OCEAN;
|
||||
}
|
||||
if(petType == TYPE_AMPHIB_LOW || petType == TYPE_AMPHIB_HIGH)
|
||||
{
|
||||
return enviroType == Utility.ENVIRO_LAND || enviroType == Utility.ENVIRO_OCEAN;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function canBeUsedByEnviroTypeFlag(petType:int, enviroTypeFlag:int) : Boolean
|
||||
{
|
||||
if(petType == TYPE_LAND_LOW)
|
||||
{
|
||||
return !Utility.isAir(enviroTypeFlag) && Utility.isLand(enviroTypeFlag);
|
||||
}
|
||||
if(petType == TYPE_LAND_HIGH)
|
||||
{
|
||||
return Utility.isAir(enviroTypeFlag) || Utility.isLand(enviroTypeFlag);
|
||||
}
|
||||
if(petType == TYPE_OCEAN_LOW || petType == TYPE_OCEAN_HIGH)
|
||||
{
|
||||
return Utility.isOcean(enviroTypeFlag);
|
||||
}
|
||||
if(petType == TYPE_AMPHIB_LOW)
|
||||
{
|
||||
return !Utility.isAir(enviroTypeFlag) && (Utility.isLand(enviroTypeFlag) || Utility.isOcean(enviroTypeFlag));
|
||||
}
|
||||
if(petType == TYPE_AMPHIB_HIGH)
|
||||
{
|
||||
return Utility.isLand(enviroTypeFlag) || Utility.isOcean(enviroTypeFlag);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canPetGoInEnviroType(petType:int, enviroTypeFlag:int) : Boolean
|
||||
{
|
||||
var petEnviroType:int = getEnviroTypeByPetType(petType,enviroTypeFlag);
|
||||
if(Utility.isSameEnviroType(enviroTypeFlag,petEnviroType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function checkIfHasPet(enviroTypeFlag:int) : Boolean
|
||||
{
|
||||
var o:Object = null;
|
||||
var petEnviroType:int = 0;
|
||||
for each(o in _myPetList)
|
||||
{
|
||||
petEnviroType = getEnviroTypeByPetType(o.type,enviroTypeFlag);
|
||||
if(petEnviroType == Utility.ENVIRO_LAND)
|
||||
{
|
||||
if(Utility.isSameEnviroType(enviroTypeFlag,petEnviroType) && !Utility.isAir(enviroTypeFlag))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(Utility.isSameEnviroType(enviroTypeFlag,petEnviroType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
package pet
|
||||
{
|
||||
import com.sbi.client.SFEvent;
|
||||
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(evt:SFEvent) : void
|
||||
{
|
||||
var data:Array = evt.obj;
|
||||
switch(data[0])
|
||||
{
|
||||
case "pl":
|
||||
onPetListResponse(data);
|
||||
break;
|
||||
case "pc":
|
||||
onPetCreateResponse(data);
|
||||
break;
|
||||
case "ps":
|
||||
onPetSwitchResponse(data);
|
||||
break;
|
||||
case "pi":
|
||||
onPetItemsResponse(data);
|
||||
break;
|
||||
case "pm":
|
||||
onPetMasteryResponse(data);
|
||||
break;
|
||||
case "pd":
|
||||
onPetDismissResponse(data);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendPetListRequest(userName:String, callback:Function = null) : void
|
||||
{
|
||||
_plCallback = callback;
|
||||
gMainFrame.server.setXtObject_Str("pl",[userName]);
|
||||
}
|
||||
|
||||
public static function sendPetCreateRequest(lBits:int, uBits:int, eBits:uint, nameIdx1:int, nameIdx2:int, callback:Function = null, isFromRedemption:Boolean = false) : void
|
||||
{
|
||||
_pcCallback = callback;
|
||||
gMainFrame.server.setXtObject_Str("pc",[lBits,uBits,eBits,nameIdx1,nameIdx2,isFromRedemption ? "1" : "0"]);
|
||||
}
|
||||
|
||||
public static function sendPetShopBuyRequest(storeId:int, itemDefId:int, lBits:int, uBits:int, eBits:uint, nameIdx1:int, nameIdx2:int, callback:Function = null, isFromRedemption:Boolean = false) : void
|
||||
{
|
||||
_pcCallback = callback;
|
||||
gMainFrame.server.setXtObject_Str("pb",[storeId,itemDefId,GenericListXtCommManager.getAvailListUniqueId(),lBits,uBits,eBits,nameIdx1,nameIdx2,isFromRedemption ? "1" : "0"]);
|
||||
}
|
||||
|
||||
public static function sendPetDismissRequest(invId:int, callback:Function = null) : void
|
||||
{
|
||||
_pdCallback = callback;
|
||||
gMainFrame.server.setXtObject_Str("pd",[invId]);
|
||||
}
|
||||
|
||||
public static function sendPetSwitchRequest(invId:int, callback:Function = null) : void
|
||||
{
|
||||
_psCallback = callback;
|
||||
gMainFrame.server.setXtObject_Str("ps",[invId]);
|
||||
}
|
||||
|
||||
public static function sendPetItemRequest(cat9:int, cat10:int, cat11:int, environment:int, callback:Function) : void
|
||||
{
|
||||
_piCallback = callback;
|
||||
gMainFrame.server.setXtObject_Str("pi",[cat9,cat10,cat11,environment]);
|
||||
}
|
||||
|
||||
public static function sendPetMasteryRequest(cat8:int, petInvId:int, callback:Function = null) : void
|
||||
{
|
||||
_pmCallback = callback;
|
||||
gMainFrame.server.setXtObject_Str("pm",[cat8,petInvId]);
|
||||
}
|
||||
|
||||
public static function petDefsResponse(dfdh:DefPacksDefHelper) : void
|
||||
{
|
||||
var petDef:Object = null;
|
||||
var data:Object = null;
|
||||
var myPetList:Array = null;
|
||||
var i:int = 0;
|
||||
var petDefs:Object = new Object();
|
||||
for each(data in dfdh.def)
|
||||
{
|
||||
petDef = {
|
||||
"defId":int(data.id),
|
||||
"mediaRefId":int(data.mediaRefId),
|
||||
"type":int(data.type),
|
||||
"isGround":PetManager.isGround(data.type),
|
||||
"title":LocalizationManager.translateIdOnly(int(data.titleStrId)),
|
||||
"titleStrId":int(data.titleStrId),
|
||||
"isMember":data.isMember == "1",
|
||||
"cost":int(data.cost),
|
||||
"status":int(data.status)
|
||||
};
|
||||
petDefs[petDef.defId] = petDef;
|
||||
}
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_PET] = null;
|
||||
PetManager.petDefs = petDefs;
|
||||
myPetList = PetManager.myPetList;
|
||||
for(i = 0; i < myPetList.length; i++)
|
||||
{
|
||||
if(myPetList[i].type == -1)
|
||||
{
|
||||
myPetList[i].type = PetManager.petTypeForDefId(myPetList[i].defId);
|
||||
}
|
||||
}
|
||||
if(canLoadPetList)
|
||||
{
|
||||
sendPetListRequest(gMainFrame.server.userName);
|
||||
}
|
||||
canLoadPetList = true;
|
||||
}
|
||||
|
||||
private static function onPetListResponse(data:Array) : void
|
||||
{
|
||||
PetManager.onPetListResponse(data,_plCallback);
|
||||
_plCallback = null;
|
||||
}
|
||||
|
||||
private static function onPetCreateResponse(data:Array) : void
|
||||
{
|
||||
PetManager.onPetCreateResponse(data,_pcCallback);
|
||||
_pcCallback = null;
|
||||
}
|
||||
|
||||
private static function onPetItemsResponse(data:Array) : void
|
||||
{
|
||||
PetManager.onPetItemsResponse(data,_piCallback);
|
||||
_piCallback = null;
|
||||
}
|
||||
|
||||
private static function onPetMasteryResponse(data:Array) : void
|
||||
{
|
||||
PetManager.onPetMasteryResponse(data,_pmCallback);
|
||||
_pmCallback = null;
|
||||
}
|
||||
|
||||
private static function onPetDismissResponse(data:Array) : void
|
||||
{
|
||||
PetManager.onPetDismissResponse(data,_pdCallback);
|
||||
_pdCallback = null;
|
||||
}
|
||||
|
||||
private static function onPetSwitchResponse(data:Array) : void
|
||||
{
|
||||
PetManager.onPetSwitchResponse(data,_psCallback);
|
||||
_psCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,322 @@
|
||||
package pet
|
||||
{
|
||||
import avatar.AvatarWorldView;
|
||||
import avatar.UserCommXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.geom.Matrix;
|
||||
import gui.GuiManager;
|
||||
import gui.SharedAvatarAnimalConstants;
|
||||
|
||||
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 = 60 * 5 * 24;
|
||||
|
||||
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(parent:AvatarWorldView, lBits:uint, uBits:uint, eBits:uint, sparkle:int = 0)
|
||||
{
|
||||
super(lBits,uBits,eBits,this.onPetLoaded);
|
||||
this._sparkle = sparkle;
|
||||
this._parent = parent;
|
||||
this._targetX = 0;
|
||||
this._bNewTarget = true;
|
||||
this._mode = 1;
|
||||
this._lastAnim = -1;
|
||||
this._bUpdateState = true;
|
||||
this._bFlip = false;
|
||||
this._bBack = false;
|
||||
this._bSpecialMove = false;
|
||||
this._parent.addChild(this);
|
||||
if(parent.userName == gMainFrame.server.userName && !GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
this.addEventListener(MouseEvent.MOUSE_DOWN,this.onClick,false,0,true);
|
||||
}
|
||||
if(_type == PetManager.TYPE_LAND_LOW || _type == PetManager.TYPE_OCEAN_LOW || _type == PetManager.TYPE_AMPHIB_LOW)
|
||||
{
|
||||
if(GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
this._y = -5;
|
||||
GuiManager.actionMgr.grayOutPetDanceBtn(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._y = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GuiManager.actionMgr.grayOutPetDanceBtn(true);
|
||||
if(GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
this._y = -5;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._y = this._airPetYOffest;
|
||||
}
|
||||
}
|
||||
this._parentLastX = this._parent.x;
|
||||
this._parentLastY = this._parent.y;
|
||||
if(GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
this._minX = 25;
|
||||
this._maxX = -30;
|
||||
this._x = this._maxX;
|
||||
this._parentLastX = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_type == PetManager.TYPE_OCEAN_LOW)
|
||||
{
|
||||
this._minX -= this._oceanPetXOffset;
|
||||
this._maxX += this._oceanPetXOffset;
|
||||
}
|
||||
else if(_type == PetManager.TYPE_LAND_LOW)
|
||||
{
|
||||
if(parent.avTypeId != SharedAvatarAnimalConstants.AV_KOALA)
|
||||
{
|
||||
this._minX -= this._petLandLowXOffset;
|
||||
}
|
||||
}
|
||||
this._x = 0;
|
||||
}
|
||||
this._targetX = 0;
|
||||
}
|
||||
|
||||
override public function destroy() : void
|
||||
{
|
||||
super.destroy();
|
||||
this.removeEventListener(MouseEvent.MOUSE_DOWN,this.onClick);
|
||||
}
|
||||
|
||||
public function heartbeat() : void
|
||||
{
|
||||
var moving:int = 0;
|
||||
var splash:int = 0;
|
||||
var matrix:Matrix = null;
|
||||
var anim:int = 0;
|
||||
if(Boolean(_content))
|
||||
{
|
||||
moving = this._parent.isPetMovingTest() ? 1 : 0;
|
||||
if(GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
if(this._parentLastX != this._parent.x)
|
||||
{
|
||||
if(this._parent.x > this._parentLastX)
|
||||
{
|
||||
if(!this._bFlip)
|
||||
{
|
||||
this._parent.flipSplash(true);
|
||||
this._bFlip = true;
|
||||
this._x = this._minX;
|
||||
}
|
||||
}
|
||||
else if(this._bFlip)
|
||||
{
|
||||
this._parent.flipSplash(false);
|
||||
this._bFlip = false;
|
||||
this._x = this._maxX;
|
||||
}
|
||||
this._parentLastX = this._parent.x;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this._targetX == 0)
|
||||
{
|
||||
this._targetX = this._parent.hFlip ? int(this._minX) : int(this._maxX);
|
||||
}
|
||||
if(this._parentLastX != this._parent.x)
|
||||
{
|
||||
this._bFlip = this._parent.x > this._parentLastX ? true : false;
|
||||
if(Math.abs(this._parentLastX - this._parent.x) > 13)
|
||||
{
|
||||
this._targetX = this._bFlip ? int(this._minX) : int(this._maxX);
|
||||
}
|
||||
this._parentLastX = this._parent.x;
|
||||
}
|
||||
if(this._parentLastY != this._parent.y)
|
||||
{
|
||||
this._bBack = this._parent.y < this._parentLastY - 10 ? true : false;
|
||||
this._parentLastY = this._parent.y;
|
||||
}
|
||||
if(this._x > this._targetX)
|
||||
{
|
||||
this._x -= 10;
|
||||
if(this._x <= this._targetX)
|
||||
{
|
||||
this._x = this._targetX;
|
||||
}
|
||||
this._bFlip = this._x == this._targetX ? true : false;
|
||||
}
|
||||
if(this._x < this._targetX)
|
||||
{
|
||||
this._x += 10;
|
||||
if(this._x > this._targetX)
|
||||
{
|
||||
this._x = this._targetX;
|
||||
}
|
||||
this._bFlip = this._x == this._targetX ? false : true;
|
||||
}
|
||||
if(this._x != this._targetX)
|
||||
{
|
||||
moving = 1;
|
||||
}
|
||||
}
|
||||
if(this._bUpdateState)
|
||||
{
|
||||
PetManager.setPetState(_content,_lBits,_uBits,_eBits);
|
||||
this._bUpdateState = false;
|
||||
}
|
||||
splash = this._parent.inSplashVolume() ? ANIM_IDLE_WATER : ANIM_IDLE;
|
||||
if(Boolean(splash) && this._parent.splashLiquid == "mud")
|
||||
{
|
||||
splash = ANIM_IDLE_MUD;
|
||||
}
|
||||
if(this._parent.splashLiquid != "mud" && this._parent.splashLiquid != "water")
|
||||
{
|
||||
splash = ANIM_IDLE;
|
||||
}
|
||||
matrix = _content.transform.matrix;
|
||||
matrix.identity();
|
||||
matrix.scale(this._bFlip ? -this._scale : this._scale,this._scale);
|
||||
matrix.translate(this._x,this._y);
|
||||
_content.transform.matrix = matrix;
|
||||
anim = splash + moving;
|
||||
if(this._bBack)
|
||||
{
|
||||
anim += 2;
|
||||
}
|
||||
if(this._lastAnim != anim)
|
||||
{
|
||||
this._lastAnim = anim;
|
||||
_content.pet.setAnim(anim);
|
||||
}
|
||||
if(this._bSpecialMove)
|
||||
{
|
||||
this._bSpecialMove = false;
|
||||
if(!moving)
|
||||
{
|
||||
_content.pet.setAnim(ANIM_CLICK + splash);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setState(cats:Array) : void
|
||||
{
|
||||
_lBits = cats[0];
|
||||
_uBits = cats[1];
|
||||
_eBits = cats[2];
|
||||
this._bUpdateState = true;
|
||||
}
|
||||
|
||||
public function setAction(actionId:int, extraId:int = 0) : void
|
||||
{
|
||||
switch(actionId)
|
||||
{
|
||||
case ACTION_CLICK:
|
||||
this.onClick();
|
||||
break;
|
||||
case ACTION_SPARKLE:
|
||||
setSparkle(extraId);
|
||||
}
|
||||
}
|
||||
|
||||
public function onClick(e:MouseEvent = null) : void
|
||||
{
|
||||
if(Boolean(e))
|
||||
{
|
||||
e.stopPropagation();
|
||||
UserCommXtCommManager.sendPetAction(WorldPet.ACTION_CLICK);
|
||||
}
|
||||
this._bSpecialMove = true;
|
||||
}
|
||||
|
||||
private function onPetLoaded(content:MovieClip) : void
|
||||
{
|
||||
if(GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
_content.pet.scaleX = _content.pet.scaleY = 2;
|
||||
}
|
||||
_content.pet.setSparkle(this._sparkle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user