mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-20 17:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,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,282 @@
|
||||
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 DEF_ID_MANITS:int = 46;
|
||||
|
||||
public static const DEF_ID_LADYBUG:int = 47;
|
||||
|
||||
public static const DEF_ID_CRICKET:int = 48;
|
||||
|
||||
public static const DEF_ID_SQUIRREL:int = 49;
|
||||
|
||||
public static const DEF_ID_MOUSE:int = 50;
|
||||
|
||||
public static const DEF_ID_FIREFLY:int = 51;
|
||||
|
||||
public static const DEF_ID_LEMUR:int = 52;
|
||||
|
||||
public static const DEF_ID_HIPPO:int = 53;
|
||||
|
||||
public static const DEF_ID_GOAT:int = 54;
|
||||
|
||||
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_:PetDef = PetManager.getPetDef(param1);
|
||||
if(_loc2_)
|
||||
{
|
||||
return _loc2_.mediaRefId;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package pet
|
||||
{
|
||||
public class PetDef
|
||||
{
|
||||
|
||||
private var _defId:int;
|
||||
|
||||
private var _mediaRefId:int;
|
||||
|
||||
private var _type:int;
|
||||
|
||||
private var _isGround:Boolean;
|
||||
|
||||
private var _title:String;
|
||||
|
||||
private var _titleStrId:int;
|
||||
|
||||
private var _isMember:Boolean;
|
||||
|
||||
private var _cost:int;
|
||||
|
||||
private var _status:int;
|
||||
|
||||
private var _diamondDefId:int;
|
||||
|
||||
public function PetDef(param1:int, param2:int, param3:int, param4:Boolean, param5:String, param6:int, param7:Boolean, param8:int, param9:int, param10:int)
|
||||
{
|
||||
super();
|
||||
_defId = param1;
|
||||
_mediaRefId = param2;
|
||||
_type = param3;
|
||||
_isGround = param4;
|
||||
_title = param5;
|
||||
_titleStrId = param6;
|
||||
_isMember = param7;
|
||||
_cost = param8;
|
||||
_status = param9;
|
||||
_diamondDefId = param10;
|
||||
}
|
||||
|
||||
public function get defId() : int
|
||||
{
|
||||
return _defId;
|
||||
}
|
||||
|
||||
public function get mediaRefId() : int
|
||||
{
|
||||
return _mediaRefId;
|
||||
}
|
||||
|
||||
public function get type() : int
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
public function get isGround() : Boolean
|
||||
{
|
||||
return _isGround;
|
||||
}
|
||||
|
||||
public function get title() : String
|
||||
{
|
||||
return _title;
|
||||
}
|
||||
|
||||
public function set title(param1:String) : void
|
||||
{
|
||||
_title = param1;
|
||||
}
|
||||
|
||||
public function get titleStrId() : int
|
||||
{
|
||||
return _titleStrId;
|
||||
}
|
||||
|
||||
public function get isMember() : Boolean
|
||||
{
|
||||
return _isMember;
|
||||
}
|
||||
|
||||
public function get cost() : int
|
||||
{
|
||||
return _cost;
|
||||
}
|
||||
|
||||
public function get status() : int
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
public function get isDiamond() : Boolean
|
||||
{
|
||||
return _diamondDefId > 0;
|
||||
}
|
||||
|
||||
public function get diamondDefId() : int
|
||||
{
|
||||
return _diamondDefId;
|
||||
}
|
||||
|
||||
public function set diamondDefId(param1:int) : void
|
||||
{
|
||||
_diamondDefId = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
package pet
|
||||
{
|
||||
import currency.CombinedCurrencyItem;
|
||||
import diamond.DiamondItem;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import inventory.Iitem;
|
||||
|
||||
public class PetItem implements Iitem
|
||||
{
|
||||
|
||||
private var _currPetDef:PetDef;
|
||||
|
||||
private var _currGuiPet:GuiPet;
|
||||
|
||||
private var _isIconLoaded:Boolean;
|
||||
|
||||
private var _imageLoadedCallback:Function;
|
||||
|
||||
private var _diamondItem:DiamondItem;
|
||||
|
||||
private var _invIdx:int;
|
||||
|
||||
private var _isShopItem:Boolean;
|
||||
|
||||
private var _endTime:uint;
|
||||
|
||||
private var _status:int;
|
||||
|
||||
public function PetItem()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(param1:int, param2:int = 0, param3:Boolean = false, param4:uint = 0, param5:Function = null, param6:DiamondItem = null) : void
|
||||
{
|
||||
_currPetDef = PetManager.getPetDef(param1);
|
||||
_status = param6 ? param6.status : _currPetDef.status;
|
||||
_isIconLoaded = false;
|
||||
_invIdx = param2;
|
||||
_diamondItem = param6;
|
||||
_isShopItem = param3;
|
||||
_endTime = param4;
|
||||
_imageLoadedCallback = param5;
|
||||
}
|
||||
|
||||
public function ifItemDiffers(param1:Iitem) : Boolean
|
||||
{
|
||||
var _loc2_:PetItem = param1 as PetItem;
|
||||
if(_loc2_)
|
||||
{
|
||||
if(_currPetDef && _currPetDef.defId == param1.defId)
|
||||
{
|
||||
if(value != _loc2_.value || isNew != _loc2_.isNew || isOnSale != _loc2_.isOnSale || _endTime != _loc2_._endTime)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get layerId() : int
|
||||
{
|
||||
throw new Error("PetItem does not contain layerId");
|
||||
}
|
||||
|
||||
public function get invIdx() : int
|
||||
{
|
||||
return _invIdx;
|
||||
}
|
||||
|
||||
public function get name() : String
|
||||
{
|
||||
return _currPetDef.title;
|
||||
}
|
||||
|
||||
public function get isMemberOnly() : Boolean
|
||||
{
|
||||
return _currPetDef.isMember;
|
||||
}
|
||||
|
||||
public function set isMemberOnly(param1:Boolean) : void
|
||||
{
|
||||
throw new Error("PetItem does not implement changing member only value");
|
||||
}
|
||||
|
||||
public function get enviroType() : int
|
||||
{
|
||||
return PetManager.getEnviroTypeByPetType(_currPetDef.type);
|
||||
}
|
||||
|
||||
public function get recycleValue() : int
|
||||
{
|
||||
if(_diamondItem)
|
||||
{
|
||||
return _diamondItem.value;
|
||||
}
|
||||
return _currPetDef.cost * gMainFrame.clientInfo.recyclePercentage;
|
||||
}
|
||||
|
||||
public function get currencyType() : int
|
||||
{
|
||||
if(_diamondItem)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function get endTime() : uint
|
||||
{
|
||||
return _endTime;
|
||||
}
|
||||
|
||||
public function set endTime(param1:uint) : void
|
||||
{
|
||||
_endTime = param1;
|
||||
}
|
||||
|
||||
public function get itemStatus() : int
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
public function set itemStatus(param1:int) : void
|
||||
{
|
||||
_status = param1;
|
||||
}
|
||||
|
||||
public function get value() : *
|
||||
{
|
||||
if(_diamondItem)
|
||||
{
|
||||
return _diamondItem.isOnSale ? _diamondItem.value : (isOnSale ? Math.ceil(_diamondItem.value * 0.5) : _diamondItem.value);
|
||||
}
|
||||
return isOnSale ? Math.ceil(_currPetDef.cost * 0.5) : _currPetDef.cost;
|
||||
}
|
||||
|
||||
public function get defId() : int
|
||||
{
|
||||
return _currPetDef.defId;
|
||||
}
|
||||
|
||||
public function set defId(param1:int) : void
|
||||
{
|
||||
throw new Error("Should not be changing this defId here");
|
||||
}
|
||||
|
||||
public function get icon() : Sprite
|
||||
{
|
||||
var _loc1_:Array = null;
|
||||
if(!_currGuiPet)
|
||||
{
|
||||
_loc1_ = PetManager.packPetBits(PetManager.createRandomPet(defId));
|
||||
_currGuiPet = PetManager.getGuiPet(defId,_loc1_[0],_loc1_[1],_loc1_[2],_currPetDef.type,_currPetDef.title,onPetLoaded);
|
||||
}
|
||||
return _currGuiPet;
|
||||
}
|
||||
|
||||
public function get largeIcon() : Sprite
|
||||
{
|
||||
return icon();
|
||||
}
|
||||
|
||||
public function get isShopItem() : Boolean
|
||||
{
|
||||
return _isShopItem;
|
||||
}
|
||||
|
||||
public function get combinedCurrencyItem() : CombinedCurrencyItem
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get isIconLoaded() : Boolean
|
||||
{
|
||||
return _isIconLoaded;
|
||||
}
|
||||
|
||||
public function get imageLoadedCallback() : Function
|
||||
{
|
||||
return _imageLoadedCallback;
|
||||
}
|
||||
|
||||
public function set imageLoadedCallback(param1:Function) : void
|
||||
{
|
||||
_imageLoadedCallback = param1;
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
_currPetDef = null;
|
||||
if(_currGuiPet)
|
||||
{
|
||||
_currGuiPet.destroy();
|
||||
_currGuiPet = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function clone() : Iitem
|
||||
{
|
||||
var _loc1_:PetItem = new PetItem();
|
||||
_loc1_.init(_currPetDef.defId,_invIdx,_diamondItem);
|
||||
_loc1_.updateValueWithNewStatus(_status);
|
||||
_loc1_.imageLoadedCallback = imageLoadedCallback;
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function get isOnSale() : Boolean
|
||||
{
|
||||
return itemStatus == 2;
|
||||
}
|
||||
|
||||
public function get isOnClearance() : Boolean
|
||||
{
|
||||
return itemStatus == 3;
|
||||
}
|
||||
|
||||
public function get isRare() : Boolean
|
||||
{
|
||||
return itemStatus == 4;
|
||||
}
|
||||
|
||||
public function get isNew() : Boolean
|
||||
{
|
||||
return itemStatus == 1;
|
||||
}
|
||||
|
||||
public function get isOcean() : Boolean
|
||||
{
|
||||
return enviroType == 1;
|
||||
}
|
||||
|
||||
public function get isLand() : Boolean
|
||||
{
|
||||
return enviroType == 0;
|
||||
}
|
||||
|
||||
public function get isDiamond() : Boolean
|
||||
{
|
||||
return _diamondItem != null;
|
||||
}
|
||||
|
||||
public function get isRareDiamond() : Boolean
|
||||
{
|
||||
return isRare && isDiamond;
|
||||
}
|
||||
|
||||
private function onPetLoaded(param1:MovieClip, param2:GuiPet) : void
|
||||
{
|
||||
_isIconLoaded = true;
|
||||
if(_isShopItem)
|
||||
{
|
||||
param1.scaleX = param1.scaleY = 3;
|
||||
param1.y += param1.height * 0.35;
|
||||
}
|
||||
if(_imageLoadedCallback != null)
|
||||
{
|
||||
if(_imageLoadedCallback.length == 0)
|
||||
{
|
||||
_imageLoadedCallback();
|
||||
}
|
||||
else
|
||||
{
|
||||
_imageLoadedCallback(param1,param2);
|
||||
}
|
||||
_imageLoadedCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function get isApproved() : Boolean
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function set isApproved(param1:Boolean) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function get isCustom() : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function updateValueWithNewStatus(param1:int) : void
|
||||
{
|
||||
if(!isRare)
|
||||
{
|
||||
itemStatus = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function get diamondItem() : DiamondItem
|
||||
{
|
||||
return _diamondItem;
|
||||
}
|
||||
|
||||
public function set diamondItem(param1:DiamondItem) : void
|
||||
{
|
||||
_diamondItem = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,202 @@
|
||||
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:int, param4:uint, param5:int, param6:int, param7:Function = null, param8:Boolean = false) : void
|
||||
{
|
||||
_pcCallback = param7;
|
||||
gMainFrame.server.setXtObject_Str("pc",[param1,GenericListXtCommManager.getAvailListUniqueId(),param2,param3,param4,param5,param6,param8 ? "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_:PetDef = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc6_:Vector.<PetDef> = new Vector.<PetDef>();
|
||||
_loc6_[0] = null;
|
||||
for each(var _loc2_:Object in param1.def)
|
||||
{
|
||||
_loc3_ = new PetDef(int(_loc2_.id),int(_loc2_.mediaRefId),int(_loc2_.type),PetManager.isGround(_loc2_.type),LocalizationManager.translateIdOnly(int(_loc2_.titleStrId)),int(_loc2_.titleStrId),_loc2_.isMember == "1",int(_loc2_.cost),int(_loc2_.status),-1);
|
||||
_loc6_[_loc3_.defId] = _loc3_;
|
||||
}
|
||||
DefPacksDefHelper.mediaArray[1046] = null;
|
||||
var _loc4_:Array = PetManager.myPetList;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc4_.length)
|
||||
{
|
||||
if(_loc4_[_loc5_].type == -1)
|
||||
{
|
||||
_loc4_[_loc5_].type = PetManager.petTypeForDefId(_loc4_[_loc5_].defId);
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
GenericListXtCommManager.requestGenericList(214,onDiamondPetListLoaded,_loc6_);
|
||||
}
|
||||
|
||||
private static function onDiamondPetListLoaded(param1:int, param2:Array, param3:Vector.<PetDef>) : void
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc4_:DiamondItem = null;
|
||||
if(DiamondXtCommManager.diamondDefsLoaded)
|
||||
{
|
||||
_loc6_ = 6;
|
||||
_loc7_ = int(param2[_loc6_++]);
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc7_)
|
||||
{
|
||||
_loc4_ = DiamondXtCommManager.getDiamondItem(int(param2[_loc6_++]));
|
||||
if(_loc4_.isPet)
|
||||
{
|
||||
param3[_loc4_.refDefId].diamondDefId = _loc4_.defId;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
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,416 @@
|
||||
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 ANIM_DANCE:int = 31;
|
||||
|
||||
public static const ANIM_SLEEP_OR_DIVE:int = 32;
|
||||
|
||||
public static const ANIM_HOP_OR_SWIRL:int = 33;
|
||||
|
||||
public static const ANIM_PLAY:int = 34;
|
||||
|
||||
public static const ANIM_SIT_OR_POSE:int = 35;
|
||||
|
||||
public static const ACTION_CLICK:int = 0;
|
||||
|
||||
public static const ACTION_SPARKLE:int = 1;
|
||||
|
||||
public static const PET_SPARKLE_TIME:int = 7200;
|
||||
|
||||
public static var _actionLookup:Array = [{
|
||||
"name":":dance:",
|
||||
"animId":31
|
||||
},{
|
||||
"name":":sleep:",
|
||||
"animId":32
|
||||
},{
|
||||
"name":":dive:",
|
||||
"animId":32
|
||||
},{
|
||||
"name":":hop:",
|
||||
"animId":33
|
||||
},{
|
||||
"name":":swirl:",
|
||||
"animId":33
|
||||
},{
|
||||
"name":":play:",
|
||||
"animId":34
|
||||
},{
|
||||
"name":":sit:",
|
||||
"animId":35
|
||||
},{
|
||||
"name":":sitNW:",
|
||||
"animId":35
|
||||
},{
|
||||
"name":":sitSW:",
|
||||
"animId":35
|
||||
},{
|
||||
"name":":sitSE:",
|
||||
"animId":35
|
||||
},{
|
||||
"name":":sitNE:",
|
||||
"animId":35
|
||||
},{
|
||||
"name":":pose:",
|
||||
"animId":35
|
||||
},{
|
||||
"name":":poseLeft:",
|
||||
"animId":35
|
||||
},{
|
||||
"name":":poseRight:",
|
||||
"animId":35
|
||||
}];
|
||||
|
||||
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, param2:Boolean) : void
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:Matrix = null;
|
||||
var _loc4_:int = 0;
|
||||
if(_content)
|
||||
{
|
||||
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(_bUpdateState)
|
||||
{
|
||||
PetManager.setPetState(_content,_lBits,_uBits,_eBits);
|
||||
_bUpdateState = false;
|
||||
}
|
||||
_loc5_ = _parent.inSplashVolume() ? 10 : 0;
|
||||
if(_loc5_ && _parent.splashLiquid == "mud")
|
||||
{
|
||||
_loc5_ = 20;
|
||||
}
|
||||
if(_parent.splashLiquid != "mud" && _parent.splashLiquid != "water")
|
||||
{
|
||||
_loc5_ = 0;
|
||||
}
|
||||
_loc3_ = _content.transform.matrix;
|
||||
_loc3_.identity();
|
||||
_loc3_.scale(_bFlip ? -_scale : _scale,_scale);
|
||||
_loc3_.translate(_x,_y - param1);
|
||||
_content.transform.matrix = _loc3_;
|
||||
_loc4_ = _loc5_ + param2;
|
||||
if(_bBack)
|
||||
{
|
||||
_loc4_ += 2;
|
||||
}
|
||||
if((param2 || _lastAnim <= 4) && _lastAnim != _loc4_)
|
||||
{
|
||||
_lastAnim = _loc4_;
|
||||
_content.pet.setAnim(_loc4_);
|
||||
}
|
||||
if(_bSpecialMove)
|
||||
{
|
||||
_bSpecialMove = false;
|
||||
if(!param2)
|
||||
{
|
||||
_content.pet.setAnim(4 + _loc5_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 setActionByName(param1:String) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
for each(var _loc3_:Object in _actionLookup)
|
||||
{
|
||||
if(_loc3_.name == param1)
|
||||
{
|
||||
_loc2_ = int(_loc3_.animId);
|
||||
if(_loc2_ > 0)
|
||||
{
|
||||
_lastAnim = _loc2_;
|
||||
if(_content)
|
||||
{
|
||||
_content.pet.setAnim(_loc2_);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private function convertAvtAnimToPetAnim() : int
|
||||
{
|
||||
switch(_parent.animId)
|
||||
{
|
||||
case 23:
|
||||
case 38:
|
||||
return 31;
|
||||
case 22:
|
||||
case 41:
|
||||
return 32;
|
||||
case 17:
|
||||
case 33:
|
||||
return 33;
|
||||
case 6:
|
||||
case 39:
|
||||
return 34;
|
||||
case 2:
|
||||
case 4:
|
||||
case 40:
|
||||
break;
|
||||
default:
|
||||
return _parent.isPetMovingTest() ? 0 : 1;
|
||||
}
|
||||
return 35;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user