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,379 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import item.Item;
|
||||
|
||||
public class AccessoryState
|
||||
{
|
||||
|
||||
private var _accShownItems:Array;
|
||||
|
||||
private var _accShownLayers:Array;
|
||||
|
||||
public var ownerAvatar:Avatar;
|
||||
|
||||
public function AccessoryState()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(initOwnerAvatar:Avatar) : void
|
||||
{
|
||||
this._accShownItems = [];
|
||||
this._accShownLayers = [];
|
||||
this.ownerAvatar = initOwnerAvatar;
|
||||
if(this.ownerAvatar.avName == null)
|
||||
{
|
||||
DebugUtility.debugTrace("break here");
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
if(Boolean(this._accShownItems))
|
||||
{
|
||||
this._accShownItems = null;
|
||||
}
|
||||
if(Boolean(this._accShownLayers))
|
||||
{
|
||||
this._accShownLayers = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function copyShownAccRef(copyFrom:AccessoryState) : void
|
||||
{
|
||||
DebugUtility.debugTrace("AccState copyAcc - ownerAvatar:" + this.ownerAvatar + (Boolean(this.ownerAvatar) ? " name:" + this.ownerAvatar.avName : "") + " copyFrom avatar:" + copyFrom.ownerAvatar + " name:" + copyFrom.ownerAvatar.avName);
|
||||
this.accShownItems = copyFrom.accShownItems;
|
||||
this.accShownLayers = copyFrom.accShownLayers;
|
||||
}
|
||||
|
||||
public function cloneShownAcc(copyFrom:AccessoryState) : void
|
||||
{
|
||||
this.accShownItems = copyFrom.accShownItems;
|
||||
for(var i:int = 0; i < this.accShownItems.length; i++)
|
||||
{
|
||||
this.accShownItems[i] = this.accShownItems[i].clone();
|
||||
}
|
||||
this.accShownLayers = copyFrom.accShownLayers;
|
||||
}
|
||||
|
||||
public function matchShownItems(copyFrom:AccessoryState, clothingItems:Array, bodyModItems:Array) : void
|
||||
{
|
||||
var j:int = 0;
|
||||
var k:int = 0;
|
||||
var numShownItems:int = int(copyFrom.accShownItems.length);
|
||||
this.accShownLayers = copyFrom.accShownLayers;
|
||||
for(var i:int = 0; i < numShownItems; i++)
|
||||
{
|
||||
if(copyFrom.accShownItems[i].type == Item.CLOTHING_TYPE)
|
||||
{
|
||||
for(j = 0; j < clothingItems.length; j++)
|
||||
{
|
||||
if(copyFrom.accShownItems[i].invIdx == clothingItems[j].invIdx)
|
||||
{
|
||||
this.accShownItems[i] = clothingItems[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(copyFrom.accShownItems[i].type == Item.BODY_MOD_TYPE)
|
||||
{
|
||||
for(k = 0; k < bodyModItems.length; k++)
|
||||
{
|
||||
if(copyFrom.accShownItems[i].invIdx == bodyModItems[k].invIdx)
|
||||
{
|
||||
this.accShownItems[i] = bodyModItems[k];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get accShownItems() : Array
|
||||
{
|
||||
return this._accShownItems;
|
||||
}
|
||||
|
||||
public function set accShownItems(setShown:Array) : void
|
||||
{
|
||||
this._accShownItems = setShown.concat();
|
||||
}
|
||||
|
||||
public function get accShownLayers() : Array
|
||||
{
|
||||
return this._accShownLayers;
|
||||
}
|
||||
|
||||
public function set accShownLayers(setShownLayers:Array) : void
|
||||
{
|
||||
this._accShownLayers = setShownLayers.concat();
|
||||
}
|
||||
|
||||
public function showAccessory(showItem:Item) : void
|
||||
{
|
||||
var i:int = 0;
|
||||
var accLength:int = 0;
|
||||
if(Boolean(showItem))
|
||||
{
|
||||
i = 0;
|
||||
accLength = int(this._accShownItems.length);
|
||||
while(i < accLength)
|
||||
{
|
||||
if(this._accShownItems[i].invIdx == showItem.invIdx)
|
||||
{
|
||||
DebugUtility.debugTrace("accessory showId:" + this._accShownItems[i].invIdx + " is already visible!");
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if(i == accLength)
|
||||
{
|
||||
showItem.setInUse(this.ownerAvatar.perUserAvId,true);
|
||||
this.adjustAvatarQuestValues(true,showItem);
|
||||
this._accShownItems.push(showItem);
|
||||
this._accShownLayers.push(-1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUtility.debugTrace("WARNING: showAccessory received a null item");
|
||||
}
|
||||
}
|
||||
|
||||
public function replaceAccessory(oldAcc:Item, newAcc:Item) : void
|
||||
{
|
||||
if(oldAcc.accId != newAcc.accId)
|
||||
{
|
||||
throw new Error("Tried to replace accessory with different accId! Layers may not match! oldId:" + oldAcc.accId + " newId:" + newAcc.accId);
|
||||
}
|
||||
var rsiLength:int = int(this._accShownItems.length);
|
||||
for(var rsai:int = 0; rsai < rsiLength; rsai++)
|
||||
{
|
||||
if(this._accShownItems[rsai] == oldAcc)
|
||||
{
|
||||
this._accShownItems[rsai] = newAcc;
|
||||
if(!newAcc.getInUse(this.ownerAvatar.perUserAvId))
|
||||
{
|
||||
this._accShownItems.splice(rsai,1);
|
||||
this._accShownLayers.splice(rsai,1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function isAccessoryVisibleByItemId(hasItemInvIdx:int) : Boolean
|
||||
{
|
||||
var itemsLength:int = int(this._accShownItems.length);
|
||||
for(var hii:int = 0; hii < itemsLength; hii++)
|
||||
{
|
||||
if(this._accShownItems[hii].invIdx == hasItemInvIdx)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isAccessoryVisibleByAccId(hasAccId:int) : Boolean
|
||||
{
|
||||
var itemsLength:int = int(this._accShownItems.length);
|
||||
for(var hii:int = 0; hii < itemsLength; hii++)
|
||||
{
|
||||
if(this._accShownItems[hii].accId == hasAccId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isAccessoryVisibleByLayer(hasLayerId:int) : Boolean
|
||||
{
|
||||
var layersLength:int = int(this._accShownLayers.length);
|
||||
for(var hli:int = 0; hli < layersLength; hli++)
|
||||
{
|
||||
if(this._accShownLayers[hli] == hasLayerId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function hideAccessory(hideItem:Item) : void
|
||||
{
|
||||
var i:int = 0;
|
||||
var accLength:int = 0;
|
||||
if(Boolean(hideItem))
|
||||
{
|
||||
i = 0;
|
||||
accLength = int(this._accShownItems.length);
|
||||
while(i < accLength)
|
||||
{
|
||||
if(this._accShownItems[i].invIdx == hideItem.invIdx)
|
||||
{
|
||||
hideItem.setInUse(this.ownerAvatar.perUserAvId,false);
|
||||
this.adjustAvatarQuestValues(false,hideItem);
|
||||
this._accShownItems.splice(i,1);
|
||||
this._accShownLayers.splice(i,1);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if(i == this._accShownItems.length)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function hideAll() : void
|
||||
{
|
||||
while(this._accShownItems.length > 0)
|
||||
{
|
||||
this.hideAccessory(this._accShownItems[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeAllItems() : void
|
||||
{
|
||||
this._accShownItems = [];
|
||||
this._accShownLayers = [];
|
||||
this.ownerAvatar.meleeAttack = [0,0];
|
||||
this.ownerAvatar.rangedAttack = [0,0];
|
||||
this.ownerAvatar.fierceAttack = [0,0];
|
||||
this.ownerAvatar.healingPower = [0,0];
|
||||
this.ownerAvatar.defense = [0,0];
|
||||
}
|
||||
|
||||
public function hideAllExceptBase() : void
|
||||
{
|
||||
var i:int = 0;
|
||||
var accLength:int = int(this._accShownItems.length);
|
||||
while(i < accLength)
|
||||
{
|
||||
if(this._accShownLayers[i] != 1)
|
||||
{
|
||||
this.hideAccessory(this._accShownItems[i]);
|
||||
accLength--;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function hideAllClothingArticles(itemsOff:Array = null) : void
|
||||
{
|
||||
var layerId:int = 0;
|
||||
var i:int = 0;
|
||||
var accLength:int = int(this._accShownItems.length);
|
||||
while(i < accLength)
|
||||
{
|
||||
layerId = int(this._accShownItems[i].layerId);
|
||||
if(layerId > 3)
|
||||
{
|
||||
if(Boolean(itemsOff))
|
||||
{
|
||||
itemsOff.push(this._accShownItems[i].invIdx);
|
||||
}
|
||||
this.hideAccessory(this._accShownItems[i]);
|
||||
accLength--;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function adjustAvatarQuestValues(add:Boolean, myitem:Item) : void
|
||||
{
|
||||
if(myitem.attack < 0)
|
||||
{
|
||||
if(add)
|
||||
{
|
||||
this.ownerAvatar.healingPower[0] += myitem.attack * -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.healingPower[0] -= myitem.attack * -1;
|
||||
}
|
||||
}
|
||||
else if(myitem.combatType == Item.COMBAT_TYPE_RANGED)
|
||||
{
|
||||
if(add)
|
||||
{
|
||||
this.ownerAvatar.rangedAttack[0] += myitem.attack;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.rangedAttack[0] -= myitem.attack;
|
||||
}
|
||||
}
|
||||
else if(add)
|
||||
{
|
||||
this.ownerAvatar.meleeAttack[0] += myitem.attack;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.meleeAttack[0] -= myitem.attack;
|
||||
}
|
||||
if(add)
|
||||
{
|
||||
this.ownerAvatar.fierceAttack[0] += myitem.fierceAttack;
|
||||
this.ownerAvatar.defense[0] += myitem.defense;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.fierceAttack[0] -= myitem.fierceAttack;
|
||||
this.ownerAvatar.defense[0] -= myitem.defense;
|
||||
}
|
||||
switch(myitem.modifierType)
|
||||
{
|
||||
case Item.MODIFIER_TYPE_DEFENSE:
|
||||
if(add)
|
||||
{
|
||||
this.ownerAvatar.defense[1] += myitem.modifierValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.defense[1] -= myitem.modifierValue;
|
||||
}
|
||||
break;
|
||||
case Item.MODIFIER_TYPE_MELEE:
|
||||
if(add)
|
||||
{
|
||||
this.ownerAvatar.meleeAttack[1] += myitem.modifierValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.meleeAttack[1] -= myitem.modifierValue;
|
||||
}
|
||||
break;
|
||||
case Item.MODIFIER_TYPE_RANGED:
|
||||
if(add)
|
||||
{
|
||||
this.ownerAvatar.rangedAttack[1] += myitem.modifierValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.rangedAttack[1] -= myitem.modifierValue;
|
||||
}
|
||||
break;
|
||||
case Item.MODIFIER_TYPE_RESTORE:
|
||||
if(add)
|
||||
{
|
||||
this.ownerAvatar.healingPower[1] += myitem.modifierValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ownerAvatar.healingPower[1] -= myitem.modifierValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,370 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import flash.events.EventDispatcher;
|
||||
import item.Inventory;
|
||||
import item.Item;
|
||||
import item.ItemXtCommManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class Avatar extends EventDispatcher
|
||||
{
|
||||
|
||||
private var _avName:String;
|
||||
|
||||
private var _userName:String;
|
||||
|
||||
private var _sfsUserId:int;
|
||||
|
||||
private var _perUserAvId:int;
|
||||
|
||||
private var _avTypeId:int;
|
||||
|
||||
private var _roomType:int;
|
||||
|
||||
private var _enviroTypeFlag:int;
|
||||
|
||||
private var _colors:Array;
|
||||
|
||||
private var _accState:AccessoryState;
|
||||
|
||||
public var inventoryClothing:Inventory;
|
||||
|
||||
public var inventoryBodyMod:Inventory;
|
||||
|
||||
public var inventoryDenFull:Inventory;
|
||||
|
||||
public var inventoryDenPartial:Inventory;
|
||||
|
||||
public var isShaman:Boolean;
|
||||
|
||||
public var shamanName:String;
|
||||
|
||||
public var shamanText:String;
|
||||
|
||||
public var rangedAttack:Array;
|
||||
|
||||
public var meleeAttack:Array;
|
||||
|
||||
public var fierceAttack:Array;
|
||||
|
||||
public var healingPower:Array;
|
||||
|
||||
public var defense:Array;
|
||||
|
||||
public function Avatar()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(uniqueAvatarId:int, avName:String, type:int, colors:Array, initAccState:AccessoryState = null, initUserName:String = "", initSfsUserId:int = -1, initRoomType:int = 0, initRangedAttack:Array = null, initMeleeAttack:Array = null, initFierceAttack:Array = null, initHealingPower:Array = null, initDefense:Array = null) : void
|
||||
{
|
||||
this.avTypeId = type;
|
||||
this._perUserAvId = uniqueAvatarId;
|
||||
this._roomType = initRoomType;
|
||||
this._avName = avName;
|
||||
this.rangedAttack = initRangedAttack == null ? [0,0] : initRangedAttack;
|
||||
this.meleeAttack = initMeleeAttack == null ? [0,0] : initMeleeAttack;
|
||||
this.fierceAttack = initFierceAttack == null ? [0,0] : initFierceAttack;
|
||||
this.healingPower = initHealingPower == null ? [0,0] : initHealingPower;
|
||||
this.defense = initDefense == null ? [0,0] : initDefense;
|
||||
if(initUserName != "")
|
||||
{
|
||||
this.userName = initUserName;
|
||||
}
|
||||
this._sfsUserId = initSfsUserId;
|
||||
this._accState = new AccessoryState();
|
||||
if(Boolean(initAccState))
|
||||
{
|
||||
DebugUtility.debugTrace("Avatar init - copying accState");
|
||||
this._accState.copyShownAccRef(initAccState);
|
||||
DebugUtility.debugTrace("old ownerAvatar:" + (Boolean(this._accState.ownerAvatar) ? this._accState.ownerAvatar.avName : this._accState.ownerAvatar));
|
||||
this._accState.ownerAvatar = this;
|
||||
DebugUtility.debugTrace("new ownerAvatar:" + this._accState.ownerAvatar.avName);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._accState.init(this);
|
||||
}
|
||||
if(Boolean(colors))
|
||||
{
|
||||
this.copyColors(colors);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._colors = null;
|
||||
}
|
||||
this.inventoryClothing = new Inventory();
|
||||
this.inventoryBodyMod = new Inventory();
|
||||
this.inventoryDenFull = new Inventory();
|
||||
this.inventoryDenPartial = new Inventory();
|
||||
this.inventoryClothing.init(this._accState);
|
||||
this.inventoryBodyMod.init(this._accState);
|
||||
this.inventoryDenFull.init(this._accState);
|
||||
this.inventoryDenPartial.init(this._accState);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
if(Boolean(this._accState))
|
||||
{
|
||||
this._accState.destroy();
|
||||
this._accState = null;
|
||||
}
|
||||
if(Boolean(this.inventoryClothing))
|
||||
{
|
||||
this.inventoryClothing.destroy();
|
||||
this.inventoryClothing = null;
|
||||
}
|
||||
if(Boolean(this.inventoryBodyMod))
|
||||
{
|
||||
this.inventoryBodyMod.destroy();
|
||||
this.inventoryBodyMod = null;
|
||||
}
|
||||
if(Boolean(this.inventoryDenFull))
|
||||
{
|
||||
this.inventoryDenFull.destroy();
|
||||
this.inventoryDenFull = null;
|
||||
}
|
||||
if(Boolean(this.inventoryDenPartial))
|
||||
{
|
||||
this.inventoryDenPartial.destroy();
|
||||
this.inventoryDenPartial = null;
|
||||
}
|
||||
this._colors = null;
|
||||
}
|
||||
|
||||
public function get perUserAvId() : int
|
||||
{
|
||||
return this._perUserAvId;
|
||||
}
|
||||
|
||||
public function set perUserAvId(setperUserAvId:int) : void
|
||||
{
|
||||
this._perUserAvId = setperUserAvId;
|
||||
}
|
||||
|
||||
public function get avName() : String
|
||||
{
|
||||
return LocalizationManager.translateAvatarName(this._avName);
|
||||
}
|
||||
|
||||
public function set avName(setAvName:String) : void
|
||||
{
|
||||
this._avName = setAvName;
|
||||
}
|
||||
|
||||
public function get userName() : String
|
||||
{
|
||||
return this._userName;
|
||||
}
|
||||
|
||||
public function set userName(setUserName:String) : void
|
||||
{
|
||||
this._userName = setUserName;
|
||||
}
|
||||
|
||||
public function get sfsUserId() : int
|
||||
{
|
||||
return this._sfsUserId;
|
||||
}
|
||||
|
||||
public function set avTypeId(newType:int) : void
|
||||
{
|
||||
this._avTypeId = newType;
|
||||
this._enviroTypeFlag = gMainFrame.userInfo.getAvatarEnviroTypeFlagByAvType(this._avTypeId);
|
||||
}
|
||||
|
||||
public function get avTypeId() : int
|
||||
{
|
||||
return this._avTypeId;
|
||||
}
|
||||
|
||||
public function get enviroTypeFlag() : int
|
||||
{
|
||||
return this._enviroTypeFlag;
|
||||
}
|
||||
|
||||
public function set colors(setColorra:Array) : void
|
||||
{
|
||||
this.setColors(setColorra[0],setColorra[1],setColorra[2]);
|
||||
}
|
||||
|
||||
public function get colors() : Array
|
||||
{
|
||||
return this._colors;
|
||||
}
|
||||
|
||||
public function get accShownItems() : Array
|
||||
{
|
||||
return this._accState.accShownItems;
|
||||
}
|
||||
|
||||
public function set roomType(newRoomType:int) : void
|
||||
{
|
||||
this._roomType = newRoomType;
|
||||
}
|
||||
|
||||
public function copyShownAccRefsFromAvatar(fromAvatar:Avatar) : void
|
||||
{
|
||||
this._accState.copyShownAccRef(fromAvatar._accState);
|
||||
this.inventoryBodyMod.itemArray = fromAvatar.inventoryBodyMod.itemArray.concat();
|
||||
if(Boolean(fromAvatar.inventoryClothing))
|
||||
{
|
||||
this.inventoryClothing.itemArray = fromAvatar.inventoryClothing.itemArray.concat();
|
||||
}
|
||||
}
|
||||
|
||||
public function cloneShownAccFromAvatar(fromAvatar:Avatar) : void
|
||||
{
|
||||
this._accState.cloneShownAcc(fromAvatar._accState);
|
||||
this.inventoryBodyMod.itemArray = fromAvatar.inventoryBodyMod.itemArray.concat();
|
||||
if(Boolean(fromAvatar.inventoryClothing))
|
||||
{
|
||||
this.inventoryClothing.itemArray = fromAvatar.inventoryClothing.itemArray.concat();
|
||||
}
|
||||
}
|
||||
|
||||
public function matchShownAcc(fromAccState:AccessoryState) : void
|
||||
{
|
||||
this._accState.matchShownItems(fromAccState,this.inventoryClothing.itemArray,this.inventoryBodyMod.itemArray);
|
||||
}
|
||||
|
||||
public function setColors(color1:uint, color2:uint, color3:uint) : void
|
||||
{
|
||||
if(this._colors == null)
|
||||
{
|
||||
this._colors = new Array(3);
|
||||
}
|
||||
var presetLayer1Colors:uint = uint(gMainFrame.userInfo.getAvatarColorLayer1InfoByAvType(this._avTypeId));
|
||||
var base1:int = color1 >> 24 & 0xFF;
|
||||
var base2:int = color1 >> 16 & 0xFF;
|
||||
var base3:int = presetLayer1Colors >> 8 & 0xFF;
|
||||
var base4:int = presetLayer1Colors & 0xFF;
|
||||
var presetLayer3Colors:uint = uint(gMainFrame.userInfo.getAvatarColorLayer3InfoByAvType(this._avTypeId));
|
||||
var eyes1:int = color3 >> 24 & 0xFF;
|
||||
var eyes2:int = presetLayer3Colors >> 16 & 0xFF;
|
||||
var eyes3:int = presetLayer3Colors >> 8 & 0xFF;
|
||||
var eyes4:int = presetLayer3Colors & 0xFF;
|
||||
this._colors[0] = uint(base1 << 24 | base2 << 16 | base3 << 8 | base4);
|
||||
this._colors[1] = color2;
|
||||
this._colors[2] = uint(eyes1 << 24 | eyes2 << 16 | eyes3 << 8 | eyes4);
|
||||
dispatchEvent(new AvatarEvent(AvatarEvent.AVATAR_CHANGED));
|
||||
}
|
||||
|
||||
public function copyColors(copyColorra:Array) : void
|
||||
{
|
||||
this.colors = copyColorra.concat();
|
||||
}
|
||||
|
||||
public function itemResponseIntegrate(itemList:Array) : void
|
||||
{
|
||||
var itemListLength:int = 0;
|
||||
var currItem:Item = null;
|
||||
var si:int = 0;
|
||||
if(Boolean(this.inventoryBodyMod) && Boolean(this.inventoryClothing))
|
||||
{
|
||||
this.removeAllItems();
|
||||
itemListLength = int(itemList.length);
|
||||
for(si = 0; si < itemListLength; si++)
|
||||
{
|
||||
currItem = itemList[si];
|
||||
if(currItem.type == Item.BODY_MOD_TYPE)
|
||||
{
|
||||
if(ItemXtCommManager.canUseItem(currItem.defId,this._avTypeId))
|
||||
{
|
||||
this.inventoryBodyMod.addItem(currItem);
|
||||
if(currItem.getInUse(this._perUserAvId))
|
||||
{
|
||||
this._accState.showAccessory(currItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(currItem.type == Item.CLOTHING_TYPE)
|
||||
{
|
||||
if(this._enviroTypeFlag == 1 << Utility.ENVIRO_LAND || this._enviroTypeFlag == 1 << Utility.ENVIRO_OCEAN || this._enviroTypeFlag == 1 < Utility.ENVIRO_AIR || currItem.enviroType == this._roomType)
|
||||
{
|
||||
this.inventoryClothing.addItem(currItem);
|
||||
if(currItem.getInUse(this._perUserAvId))
|
||||
{
|
||||
this._accState.showAccessory(currItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUtility.debugTrace("ERROR: Bad item type: " + currItem.type);
|
||||
}
|
||||
}
|
||||
dispatchEvent(new AvatarEvent(AvatarEvent.AVATAR_CHANGED));
|
||||
}
|
||||
}
|
||||
|
||||
public function accStateShowAccessory(showItem:Item, hideItemCallback:Function = null) : void
|
||||
{
|
||||
var tempItem:Item = null;
|
||||
var items:Array = showItem.type == Item.BODY_MOD_TYPE ? this.inventoryBodyMod.itemArray : this.inventoryClothing.itemArray;
|
||||
for(var i:int = 0; i < items.length; i++)
|
||||
{
|
||||
tempItem = items[i];
|
||||
if(tempItem.layerId == showItem.layerId && tempItem.getInUse(this._perUserAvId))
|
||||
{
|
||||
if(tempItem != showItem)
|
||||
{
|
||||
this.accStateHideAccessory(tempItem,false);
|
||||
if(hideItemCallback != null)
|
||||
{
|
||||
hideItemCallback(tempItem);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._accState.showAccessory(showItem);
|
||||
dispatchEvent(new AvatarEvent(AvatarEvent.AVATAR_CHANGED));
|
||||
}
|
||||
|
||||
public function accStateHideAccessory(hideItem:Item, bDispatchEvent:Boolean = true) : void
|
||||
{
|
||||
this._accState.hideAccessory(hideItem);
|
||||
if(bDispatchEvent)
|
||||
{
|
||||
dispatchEvent(new AvatarEvent(AvatarEvent.AVATAR_CHANGED));
|
||||
}
|
||||
}
|
||||
|
||||
public function removeAllItems() : void
|
||||
{
|
||||
this.inventoryBodyMod.itemArray = [];
|
||||
this.inventoryClothing.itemArray = [];
|
||||
this._accState.removeAllItems();
|
||||
}
|
||||
|
||||
public function get accState() : AccessoryState
|
||||
{
|
||||
return this._accState;
|
||||
}
|
||||
|
||||
public function clone(avatarToClone:Avatar) : void
|
||||
{
|
||||
this._avTypeId = avatarToClone.avTypeId;
|
||||
this._perUserAvId = avatarToClone.perUserAvId;
|
||||
this._avName = avatarToClone.avName;
|
||||
this.userName = avatarToClone.userName;
|
||||
this._sfsUserId = avatarToClone._sfsUserId;
|
||||
this._accState = new AccessoryState();
|
||||
this._accState.cloneShownAcc(avatarToClone.accState);
|
||||
this._accState.ownerAvatar = this;
|
||||
this.copyColors(avatarToClone.colors);
|
||||
this.inventoryClothing = new Inventory();
|
||||
this.inventoryClothing.clone(avatarToClone.inventoryClothing);
|
||||
this.inventoryBodyMod = new Inventory();
|
||||
this.inventoryBodyMod.clone(avatarToClone.inventoryBodyMod);
|
||||
this.inventoryDenFull = new Inventory();
|
||||
this.inventoryDenFull.clone(avatarToClone.inventoryDenFull);
|
||||
this.inventoryDenPartial = new Inventory();
|
||||
this.inventoryDenPartial.clone(avatarToClone.inventoryDenPartial);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.graphics.LayerAnim;
|
||||
import item.Item;
|
||||
|
||||
public class AvatarEditorView extends AvatarView
|
||||
{
|
||||
|
||||
public function AvatarEditorView()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function init(worldAvatar:Avatar, avTypeCallback:Function = null) : void
|
||||
{
|
||||
var i:int = 0;
|
||||
var j:int = 0;
|
||||
_avatar = new Avatar();
|
||||
_avatar.init(worldAvatar.perUserAvId,"editorAvatar",worldAvatar.avTypeId,worldAvatar.colors,null,"",-1,0,worldAvatar.rangedAttack,worldAvatar.meleeAttack,worldAvatar.fierceAttack,worldAvatar.healingPower,worldAvatar.defense);
|
||||
if(Boolean(worldAvatar.inventoryClothing.itemArray))
|
||||
{
|
||||
_avatar.inventoryClothing.itemArray = worldAvatar.inventoryClothing.itemArray.concat();
|
||||
for(i = 0; i < _avatar.inventoryClothing.itemArray.length; i++)
|
||||
{
|
||||
_avatar.inventoryClothing.itemArray[i].makeSmallIcon();
|
||||
}
|
||||
}
|
||||
if(Boolean(worldAvatar.inventoryBodyMod.itemArray))
|
||||
{
|
||||
_avatar.inventoryBodyMod.itemArray = worldAvatar.inventoryBodyMod.itemArray.concat();
|
||||
for(j = 0; j < _avatar.inventoryBodyMod.itemArray.length; j++)
|
||||
{
|
||||
_avatar.inventoryBodyMod.itemArray[j].makeSmallIcon();
|
||||
}
|
||||
}
|
||||
_avatar.matchShownAcc(worldAvatar.accState);
|
||||
_avatar.addEventListener(AvatarEvent.AVATAR_CHANGED,avatarChanged,false,0,true);
|
||||
_layerAnim = LayerAnim.getNew();
|
||||
_layerAnim.avDefId = _avatar.avTypeId;
|
||||
_layerAnim.layers = AvatarUtility.layerArrayForItemsAndColors(worldAvatar.inventoryClothing.itemArray.concat(worldAvatar.inventoryBodyMod.itemArray.concat()),worldAvatar.colors,worldAvatar.perUserAvId);
|
||||
this.addChild(_layerAnim.bitmap);
|
||||
}
|
||||
|
||||
override public function destroy(destroyAvatar:Boolean = true) : void
|
||||
{
|
||||
if(destroyAvatar && Boolean(_avatar))
|
||||
{
|
||||
_avatar.removeEventListener(AvatarEvent.AVATAR_CHANGED,avatarChanged);
|
||||
_avatar.destroy();
|
||||
_avatar = null;
|
||||
}
|
||||
avTypeChangedCallback = null;
|
||||
LayerAnim.destroy(_layerAnim);
|
||||
_layerAnim = null;
|
||||
}
|
||||
|
||||
public function get colors() : Array
|
||||
{
|
||||
return _avatar.colors;
|
||||
}
|
||||
|
||||
public function set colors(colors:Array) : void
|
||||
{
|
||||
_avatar.colors = colors;
|
||||
}
|
||||
|
||||
public function get accState() : AccessoryState
|
||||
{
|
||||
return _avatar.accState;
|
||||
}
|
||||
|
||||
public function showAccessory(showItem:Item, callback:Function = null) : void
|
||||
{
|
||||
_avatar.accStateShowAccessory(showItem,callback);
|
||||
}
|
||||
|
||||
public function hideAccessory(hideItem:Item) : void
|
||||
{
|
||||
_avatar.accStateHideAccessory(hideItem);
|
||||
}
|
||||
|
||||
public function get viewAvatar() : Avatar
|
||||
{
|
||||
return _avatar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package avatar
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class AvatarEvent extends Event
|
||||
{
|
||||
|
||||
public static const AVATAR_CHANGED:String = "OnAvatarChanged";
|
||||
|
||||
public function AvatarEvent(type:String)
|
||||
{
|
||||
super(type);
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new AvatarEvent(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
package avatar
|
||||
{
|
||||
import localization.LocalizationManager;
|
||||
import pet.PetManager;
|
||||
|
||||
public class AvatarInfo
|
||||
{
|
||||
|
||||
public var perUserAvId:int;
|
||||
|
||||
public var userName:String;
|
||||
|
||||
public var type:int;
|
||||
|
||||
public var colors:Array;
|
||||
|
||||
public var currEnviroType:int;
|
||||
|
||||
public var landPetInvId:int;
|
||||
|
||||
public var oceanPetInvId:int;
|
||||
|
||||
public var questXp:int;
|
||||
|
||||
public var questLevel:int;
|
||||
|
||||
public var questXPPercentage:int;
|
||||
|
||||
public var questHealthPercentage:int;
|
||||
|
||||
public var questTorchStatus:Boolean;
|
||||
|
||||
public var isDead:Boolean;
|
||||
|
||||
public var healthBase:int;
|
||||
|
||||
public var attackBase:int;
|
||||
|
||||
public var attackMax:int;
|
||||
|
||||
public var defenseBase:int;
|
||||
|
||||
public var defenseMax:int;
|
||||
|
||||
private var _currPet:Object;
|
||||
|
||||
private var _avName:String;
|
||||
|
||||
public function AvatarInfo()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(initPerUserAvatarId:int = -1, initAvName:String = "", initUserName:String = "", initType:int = -1, initColors:Array = null, initRoomType:int = 0, initCurrPet:Object = null, initLandPetInvId:int = 0, initOceanPetInvId:int = 0, initQuestXp:int = 0, initQuestLevel:int = 0, initQuestXPPercentage:int = 0, initHealthBase:int = 0, initAttackBase:int = 0, initAttackMax:int = 0, initDefenseMax:int = 0, initDefenseBase:int = 0, initQuestHealthPercentage:int = 100, initQuestTorchStatus:Boolean = false) : void
|
||||
{
|
||||
this.isDead = false;
|
||||
this.perUserAvId = initPerUserAvatarId;
|
||||
this._avName = initAvName;
|
||||
this.userName = initUserName;
|
||||
this.type = initType;
|
||||
this.colors = initColors == null ? [286331153,286331153,286331153] : initColors;
|
||||
this.currEnviroType = initRoomType;
|
||||
this.landPetInvId = initLandPetInvId;
|
||||
this.oceanPetInvId = initOceanPetInvId;
|
||||
this.questXp = initQuestXp;
|
||||
this.questLevel = initQuestLevel;
|
||||
this.questXPPercentage = initQuestXPPercentage;
|
||||
this.questHealthPercentage = initQuestHealthPercentage;
|
||||
this.questTorchStatus = initQuestTorchStatus;
|
||||
this.attackBase = initAttackBase;
|
||||
this.attackMax = initAttackMax;
|
||||
this.defenseBase = initDefenseBase;
|
||||
this.defenseMax = initDefenseMax;
|
||||
this.healthBase = initHealthBase;
|
||||
this._currPet = initCurrPet;
|
||||
}
|
||||
|
||||
public function get currPet() : Object
|
||||
{
|
||||
if(this.userName == gMainFrame.userInfo.myUserName)
|
||||
{
|
||||
return PetManager.myActivePet;
|
||||
}
|
||||
return this._currPet;
|
||||
}
|
||||
|
||||
public function set currPet(o:Object) : void
|
||||
{
|
||||
if(this.userName != gMainFrame.userInfo.myUserName)
|
||||
{
|
||||
this._currPet = o;
|
||||
}
|
||||
}
|
||||
|
||||
public function getItems(withBodyMods:Boolean = false) : Array
|
||||
{
|
||||
var userInf:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(this.userName);
|
||||
if(Boolean(userInf))
|
||||
{
|
||||
return userInf.getPartialItemList(this.type,withBodyMods);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getFullItems(withBodyMods:Boolean = false) : Array
|
||||
{
|
||||
var userInf:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(this.userName);
|
||||
if(Boolean(userInf))
|
||||
{
|
||||
return userInf.getFullItemList(withBodyMods);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function set fullItemList(list:Array) : void
|
||||
{
|
||||
var userInf:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(this.userName);
|
||||
if(Boolean(userInf))
|
||||
{
|
||||
userInf.fullItemList = list;
|
||||
}
|
||||
}
|
||||
|
||||
public function get denItems() : Array
|
||||
{
|
||||
var userInf:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(this.userName);
|
||||
if(Boolean(userInf))
|
||||
{
|
||||
return userInf.denItemsFull;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get achievements() : Array
|
||||
{
|
||||
var userInf:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(this.userName);
|
||||
if(Boolean(userInf))
|
||||
{
|
||||
return userInf.achievements;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function set denItems(items:Array) : void
|
||||
{
|
||||
var userInfo:UserInfo = null;
|
||||
if(Boolean(items))
|
||||
{
|
||||
userInfo = gMainFrame.userInfo.getUserInfoByUserName(this.userName);
|
||||
if(Boolean(userInfo))
|
||||
{
|
||||
userInfo.denItemsFull = items;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get accountType() : int
|
||||
{
|
||||
var userInfo:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(this.userName);
|
||||
if(Boolean(userInfo))
|
||||
{
|
||||
return userInfo.accountType;
|
||||
}
|
||||
return Utility.NON_MEMBER;
|
||||
}
|
||||
|
||||
public function get isMember() : Boolean
|
||||
{
|
||||
return Utility.isMember(this.accountType);
|
||||
}
|
||||
|
||||
public function get avName() : String
|
||||
{
|
||||
return LocalizationManager.translateAvatarName(this._avName);
|
||||
}
|
||||
|
||||
public function set avName(name:String) : void
|
||||
{
|
||||
this._avName = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,951 @@
|
||||
package avatar
|
||||
{
|
||||
import buddy.BuddyEvent;
|
||||
import com.sbi.analytics.SBTracker;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.Event;
|
||||
import flash.media.SoundTransform;
|
||||
import gui.BuddyCard;
|
||||
import gui.BuddyManager;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import gui.GuiNameTypeScreen;
|
||||
import item.ItemXtCommManager;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
import pet.PetManager;
|
||||
import quest.QuestManager;
|
||||
import room.RoomManagerWorld;
|
||||
import room.RoomXtCommManager;
|
||||
|
||||
public class AvatarSwitch
|
||||
{
|
||||
|
||||
public static var avatars:Array;
|
||||
|
||||
public static var activeAvatarIdx:int;
|
||||
|
||||
public static var playerUserInfo:UserInfo;
|
||||
|
||||
public static var nameTypeScreen:GuiNameTypeScreen;
|
||||
|
||||
public static var playerUsername:String;
|
||||
|
||||
public static var playerSfsUserId:int;
|
||||
|
||||
public static var isSlotAvail:int;
|
||||
|
||||
public static var isAddingSlot:Boolean;
|
||||
|
||||
public static var availSlotFlags:int;
|
||||
|
||||
public static var isChoosing:Boolean;
|
||||
|
||||
private static var _addSlotCallback:Function;
|
||||
|
||||
private static var _switchCallback:Function;
|
||||
|
||||
private static var _addIdx:int;
|
||||
|
||||
private static var _switchIdx:int;
|
||||
|
||||
private static var _addAvatarCallback:Function;
|
||||
|
||||
private static var _addAvatar:Avatar;
|
||||
|
||||
private static var _addAvName:String;
|
||||
|
||||
private static var _removeCallback:Function;
|
||||
|
||||
private static var _removeIdx:int;
|
||||
|
||||
private static var _isChoosing:Boolean;
|
||||
|
||||
private static var _asTransformVec:Vector.<MediaHelper>;
|
||||
|
||||
private static var _secondChosenAvtIdx:int;
|
||||
|
||||
private static var _numOpenNonMemberSlots:int;
|
||||
|
||||
private static var _caIdx:int;
|
||||
|
||||
private static var _avatarName:String;
|
||||
|
||||
private static var _avatarNameIndexes:Array;
|
||||
|
||||
private static var _shopId:int;
|
||||
|
||||
private static var _itemInShopDefId:int;
|
||||
|
||||
private static var _status:int;
|
||||
|
||||
public static const ASTRANSFORM_MEDIA_ID_TOP:int = 33;
|
||||
|
||||
public static const ASTRANSFORM_MEDIA_ID_BOTTOM:int = 34;
|
||||
|
||||
public static const ASTRANSFORM_OCEAN_MEDIA_ID_TOP:int = 1171;
|
||||
|
||||
public static const ASTRANSFORM_OCEAN_MEDIA_ID_BOTTOM:int = 1172;
|
||||
|
||||
public function AvatarSwitch()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
_asTransformVec = new Vector.<MediaHelper>();
|
||||
_secondChosenAvtIdx = -1;
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
_asTransformVec = null;
|
||||
}
|
||||
|
||||
public static function playerInfoSet() : void
|
||||
{
|
||||
var i:int = 0;
|
||||
if(playerUserInfo == null)
|
||||
{
|
||||
playerUserInfo = gMainFrame.userInfo.playerUserInfo;
|
||||
playerUsername = playerUserInfo.userName;
|
||||
playerSfsUserId = gMainFrame.server.userId;
|
||||
avatars = [];
|
||||
updateAvatars();
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i = 0; i < avatars.length; i++)
|
||||
{
|
||||
if(Boolean(avatars[i]))
|
||||
{
|
||||
if(avatars[i].perUserAvId == gMainFrame.userInfo.myPerUserAvId)
|
||||
{
|
||||
if(i != 0)
|
||||
{
|
||||
avatars.unshift(avatars[i]);
|
||||
avatars.splice(i + 1,1);
|
||||
activeAvatarIdx = _switchIdx = 0;
|
||||
}
|
||||
}
|
||||
avatars[i].roomType = AvatarManager.roomEnviroType;
|
||||
}
|
||||
}
|
||||
avatars[activeAvatarIdx] = AvatarManager.playerAvatar;
|
||||
}
|
||||
}
|
||||
|
||||
public static function updateSlotPositions() : void
|
||||
{
|
||||
var tempAvatars:Array = avatars.slice();
|
||||
var tempSwitchperUserAvId:int = int(avatars[_switchIdx].perUserAvId);
|
||||
var tempActiveAvatarperUserAvId:int = int(avatars[activeAvatarIdx].perUserAvId);
|
||||
var numSkipped:int = 0;
|
||||
avatars = [];
|
||||
for(var i:int = 0; i < tempAvatars.length; i++)
|
||||
{
|
||||
if(tempAvatars[i] != null)
|
||||
{
|
||||
avatars.push(tempAvatars[i]);
|
||||
if(tempSwitchperUserAvId == tempAvatars[i].perUserAvId)
|
||||
{
|
||||
_switchIdx = i - numSkipped;
|
||||
AvatarXtCommManager.avSlotInfo[tempSwitchperUserAvId].slotId = _switchIdx;
|
||||
}
|
||||
if(tempActiveAvatarperUserAvId == tempAvatars[i].perUserAvId)
|
||||
{
|
||||
activeAvatarIdx = i - numSkipped;
|
||||
AvatarXtCommManager.avSlotInfo[tempActiveAvatarperUserAvId].slotId = activeAvatarIdx;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
numSkipped++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function updateAvatars() : void
|
||||
{
|
||||
var uai:AvatarInfo = null;
|
||||
var avatarsLength:int = 0;
|
||||
var i:int = 0;
|
||||
var av:Avatar = null;
|
||||
var sa:Avatar = null;
|
||||
for each(uai in playerUserInfo.avList)
|
||||
{
|
||||
if(uai.perUserAvId == playerUserInfo.currPerUserAvId)
|
||||
{
|
||||
av = AvatarManager.playerAvatar;
|
||||
}
|
||||
else
|
||||
{
|
||||
av = avatars[AvatarXtCommManager.avSlotInfo[uai.perUserAvId].slotId];
|
||||
if(!av)
|
||||
{
|
||||
av = new Avatar();
|
||||
av = AvatarUtility.generateNew(uai.perUserAvId,av,uai.userName,playerSfsUserId,AvatarManager.roomEnviroType);
|
||||
}
|
||||
}
|
||||
avatars[AvatarXtCommManager.avSlotInfo[uai.perUserAvId].slotId] = av;
|
||||
av = null;
|
||||
}
|
||||
avatarsLength = int(avatars.length);
|
||||
for(i = 0; i < avatarsLength; i++)
|
||||
{
|
||||
if(avatars[i] != null)
|
||||
{
|
||||
sa = avatars[i];
|
||||
if(playerUserInfo.currPerUserAvId == sa.perUserAvId)
|
||||
{
|
||||
activeAvatarIdx = _switchIdx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function shouldChoose() : Boolean
|
||||
{
|
||||
var nonMemberAvatars:int = 0;
|
||||
var numOceanOnlyAvatars:int = 0;
|
||||
var memberAvatars:int = 0;
|
||||
for(var i:int = 0; i < avatars.length; i++)
|
||||
{
|
||||
if(Boolean(avatars[i]))
|
||||
{
|
||||
if(isMemberOnlyAvatar(i))
|
||||
{
|
||||
memberAvatars++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(avatars[i].enviroTypeFlag == 2)
|
||||
{
|
||||
numOceanOnlyAvatars++;
|
||||
}
|
||||
nonMemberAvatars++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(nonMemberAvatars < 3 && nonMemberAvatars > 0 && numOceanOnlyAvatars < 2 && nonMemberAvatars != numOceanOnlyAvatars)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function isMemberOnlyAvatar(index:int) : Boolean
|
||||
{
|
||||
return gMainFrame.userInfo.getAvatarMemberInfoByAvType(avatars[index].avTypeId);
|
||||
}
|
||||
|
||||
public static function get numTotalAvatars() : int
|
||||
{
|
||||
var numAvts:int = 0;
|
||||
for(var i:int = 0; i < avatars.length; i++)
|
||||
{
|
||||
if(Boolean(avatars[i]))
|
||||
{
|
||||
numAvts++;
|
||||
}
|
||||
}
|
||||
return numAvts;
|
||||
}
|
||||
|
||||
public static function getNumUsableLandAvatars(isChoosing:Boolean, isMember:Boolean) : int
|
||||
{
|
||||
var num:int = 0;
|
||||
for(var i:int = 0; i < avatars.length; i++)
|
||||
{
|
||||
if(Boolean(avatars[i]) && Utility.isLand(avatars[i].enviroTypeFlag))
|
||||
{
|
||||
if(isChoosing || isMember)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
else if((availSlotFlags & 1 << AvatarXtCommManager.avSlotInfo[avatars[i].perUserAvId].avInvId) > 0)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public static function get numMemberAvatars() : int
|
||||
{
|
||||
var num:int = 0;
|
||||
for(var i:int = 0; i < avatars.length; i++)
|
||||
{
|
||||
if(Boolean(avatars[i]) && Boolean(gMainFrame.userInfo.getAvatarMemberInfoByAvType(avatars[i].avTypeId)))
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public static function get numNonMemberAvatars() : int
|
||||
{
|
||||
var num:int = 0;
|
||||
for(var i:int = 0; i < avatars.length; i++)
|
||||
{
|
||||
if(Boolean(avatars[i]) && !gMainFrame.userInfo.getAvatarMemberInfoByAvType(avatars[i].avTypeId))
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public static function get numNonMemberOceanAvatars() : int
|
||||
{
|
||||
var num:int = 0;
|
||||
for(var i:int = 0; i < avatars.length; i++)
|
||||
{
|
||||
if(Boolean(avatars[i]) && Boolean(!gMainFrame.userInfo.getAvatarMemberInfoByAvType(avatars[i].avTypeId)) && avatars[i].enviroTypeFlag == 2)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public static function getNumNonMemberAvailableAvatars() : int
|
||||
{
|
||||
var num:int = 0;
|
||||
for(var i:int = 0; i < avatars.length; i++)
|
||||
{
|
||||
if(Boolean(avatars[i]) && Boolean(!gMainFrame.userInfo.getAvatarMemberInfoByAvType(avatars[i].avTypeId)) && (availSlotFlags & 1 << AvatarXtCommManager.avSlotInfo[avatars[i].perUserAvId].avInvId) > 0)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public static function get numAvailAvatars() : int
|
||||
{
|
||||
var numAvailAvts:int = 0;
|
||||
for(var i:int = 0; i < avatars.length; i++)
|
||||
{
|
||||
if(Boolean(avatars[i]) && (availSlotFlags & 1 << AvatarXtCommManager.avSlotInfo[avatars[i].perUserAvId].avInvId) > 0)
|
||||
{
|
||||
numAvailAvts++;
|
||||
}
|
||||
}
|
||||
return numAvailAvts;
|
||||
}
|
||||
|
||||
public static function isSwitching() : Boolean
|
||||
{
|
||||
return Boolean(activeAvatarIdx != _switchIdx);
|
||||
}
|
||||
|
||||
public static function isSlotAvailable(slotIdx:int) : Boolean
|
||||
{
|
||||
return (availSlotFlags & 1 << AvatarXtCommManager.avSlotInfo[avatars[slotIdx].perUserAvId].avInvId) > 0;
|
||||
}
|
||||
|
||||
public static function get numOpenNonMemberSlots() : int
|
||||
{
|
||||
return _numOpenNonMemberSlots;
|
||||
}
|
||||
|
||||
public static function set numOpenNonMemberSlots(value:int) : void
|
||||
{
|
||||
_numOpenNonMemberSlots = value;
|
||||
}
|
||||
|
||||
public static function addSlot(addSlotCallback:Function) : void
|
||||
{
|
||||
_addSlotCallback = addSlotCallback;
|
||||
AvatarXtCommManager.requestAvatarBuy(showNewAvatarPopup);
|
||||
}
|
||||
|
||||
public static function showNewAvatarPopup(success:Boolean) : void
|
||||
{
|
||||
if(success)
|
||||
{
|
||||
isAddingSlot = false;
|
||||
addNewWorldAvatar(_caIdx,_avatarName,_avatarNameIndexes);
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(_addSlotCallback != null)
|
||||
{
|
||||
_addSlotCallback(success,true);
|
||||
}
|
||||
}
|
||||
|
||||
public static function addAvatar(index:int, addingSlot:Boolean = false, addAvatarCallback:Function = null, isChoosing:Boolean = false, isChoosingOceanAnimal:Boolean = false, avatarTypeToShow:int = -1, skipToNameScreen:Boolean = false, currencyType:int = 0, specialValue:int = -1, shopId:int = -1, itemDefId:int = -1) : void
|
||||
{
|
||||
_addIdx = index;
|
||||
_addAvatarCallback = addAvatarCallback;
|
||||
_isChoosing = isChoosing;
|
||||
_shopId = shopId;
|
||||
_itemInShopDefId = itemDefId;
|
||||
isAddingSlot = addingSlot;
|
||||
var numNonMemberAvatars:int = AvatarUtility.numNonMemberAvatars();
|
||||
GuiManager.openAvatarCreator(isChoosingOceanAnimal,numNonMemberAvatars >= 1 && numNonMemberAvatars - numNonMemberOceanAvatars > 0 ? false : isChoosing,avatarTypeToShow,skipToNameScreen,currencyType,specialValue);
|
||||
}
|
||||
|
||||
public static function set addAvatarCallback(value:Function) : void
|
||||
{
|
||||
_addAvatarCallback = value;
|
||||
}
|
||||
|
||||
public static function addNewWorldAvatar(caIdx:int, avatarName:String, avatarNameIndexes:Array, isShopBuy:Boolean = false) : void
|
||||
{
|
||||
var nameIndex1:int = 0;
|
||||
var nameIndex2:int = 0;
|
||||
if(isAddingSlot)
|
||||
{
|
||||
_caIdx = caIdx;
|
||||
_avatarName = avatarName;
|
||||
_avatarNameIndexes = avatarNameIndexes;
|
||||
addSlot(_addAvatarCallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
_addAvatar = AvatarUtility.creationAvatars[AvatarUtility.findAvatarIndexByType(caIdx)];
|
||||
_addAvName = avatarName;
|
||||
if(_addAvatar != null && avatarNameIndexes[0] != null && avatarNameIndexes[1] != null && avatarNameIndexes[2] != null)
|
||||
{
|
||||
nameIndex1 = LocalizationManager.isCurrLanguageReversed() ? int(avatarNameIndexes[2]) : int(avatarNameIndexes[1]);
|
||||
nameIndex2 = LocalizationManager.isCurrLanguageReversed() ? int(avatarNameIndexes[1]) : int(avatarNameIndexes[2]);
|
||||
SBTracker.pop();
|
||||
if(_shopId != -1 && isShopBuy)
|
||||
{
|
||||
AvatarXtCommManager.requestAvatarShopBuy([_shopId,_itemInShopDefId,GenericListXtCommManager.getAvailListUniqueId(),avatarNameIndexes[0],nameIndex1,nameIndex2,_addAvatar.avTypeId],addAvatarResponse);
|
||||
}
|
||||
else
|
||||
{
|
||||
AvatarXtCommManager.requestAvatarAdd([avatarNameIndexes[0],nameIndex1,nameIndex2,_addAvatar.avTypeId],addAvatarResponse);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUtility.debugTrace("Failed to request add avatar with addAvatar = " + _addAvatar + " AvatarNameIndexes[0] = " + avatarNameIndexes[0] + " AvatarNameIndexes[1] = " + avatarNameIndexes[1] + " AvatarNameIndexes[2] = " + avatarNameIndexes[2] + " addAvatar.avTypeId = " + (_addAvatar != null ? _addAvatar.avTypeId : null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function addAvatarResponse(status:int, newPerUserAvId:int, newAvInvId:int) : void
|
||||
{
|
||||
var addAvCopy:Avatar = null;
|
||||
_status = status;
|
||||
if(_status == 1)
|
||||
{
|
||||
addAvCopy = new Avatar();
|
||||
addAvCopy.init(newPerUserAvId,_addAvName,_addAvatar.avTypeId,null,null,playerUsername,playerSfsUserId);
|
||||
addAvCopy.copyColors(_addAvatar.colors);
|
||||
addAvCopy.cloneShownAccFromAvatar(_addAvatar);
|
||||
addAvCopy.accState.hideAllClothingArticles();
|
||||
if(_isChoosing)
|
||||
{
|
||||
AvatarXtCommManager.avSlotInfo[addAvCopy.perUserAvId] = {
|
||||
"slotId":_addIdx,
|
||||
"avInvId":newAvInvId
|
||||
};
|
||||
avatars[_addIdx] = addAvCopy;
|
||||
AvatarXtCommManager.requestADForAvatar(addAvCopy.perUserAvId,true,onChoosingAdReceive,addAvCopy);
|
||||
return;
|
||||
}
|
||||
if((availSlotFlags & 1 << newAvInvId) == 0)
|
||||
{
|
||||
availSlotFlags |= 1 << newAvInvId;
|
||||
}
|
||||
if(!Utility.isSameEnviroType(addAvCopy.enviroTypeFlag,AvatarManager.roomEnviroType))
|
||||
{
|
||||
avatars.splice(_addIdx,1);
|
||||
avatars.unshift(addAvCopy);
|
||||
AvatarXtCommManager.avSlotInfo[addAvCopy.perUserAvId] = {
|
||||
"slotId":0,
|
||||
"avInvId":newAvInvId
|
||||
};
|
||||
_addIdx = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
AvatarXtCommManager.avSlotInfo[addAvCopy.perUserAvId] = {
|
||||
"slotId":_addIdx,
|
||||
"avInvId":newAvInvId
|
||||
};
|
||||
avatars[_addIdx] = addAvCopy;
|
||||
}
|
||||
switchAvatars(_addIdx);
|
||||
}
|
||||
if(_status != 1)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(_addAvatarCallback != null)
|
||||
{
|
||||
_addAvatarCallback(_status);
|
||||
_addAvatarCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function onChoosingAdReceive() : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(_addAvatarCallback != null)
|
||||
{
|
||||
_addAvatarCallback(_status);
|
||||
_addAvatarCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function switchAvatars(switchIdx:int, switchAvatarsCallback:Function = null) : void
|
||||
{
|
||||
if(switchIdx < 0 || switchIdx >= avatars.length)
|
||||
{
|
||||
throw new Error("Invalid switchIdx:" + switchIdx);
|
||||
}
|
||||
_switchCallback = switchAvatarsCallback;
|
||||
_switchIdx = switchIdx;
|
||||
RoomXtCommManager.isSwitching = true;
|
||||
_isChoosing = false;
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
RoomManagerWorld.instance.forceStopMovement();
|
||||
AvatarXtCommManager.requestAvatarSwitch([avatars[switchIdx].perUserAvId]);
|
||||
}
|
||||
|
||||
public static function setAvatarSwitchCallback(switchAvatarsCallback:Function) : void
|
||||
{
|
||||
_switchCallback = switchAvatarsCallback;
|
||||
}
|
||||
|
||||
public static function avatarSwitchResponse(data:Array) : void
|
||||
{
|
||||
var sfsUserId:int = 0;
|
||||
var savw:AvatarWorldView = null;
|
||||
var asTransformTop:MediaHelper = null;
|
||||
var asTransformBtm:MediaHelper = null;
|
||||
var ftci:int = 0;
|
||||
var ftcdo:DisplayObject = null;
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(!_isChoosing)
|
||||
{
|
||||
if(_addAvatarCallback != null)
|
||||
{
|
||||
_addAvatarCallback(true);
|
||||
_addAvatarCallback = null;
|
||||
}
|
||||
}
|
||||
var asi:int = 2;
|
||||
var success:Boolean = Boolean(int(data[int(asi++)]));
|
||||
if(success)
|
||||
{
|
||||
sfsUserId = int(data[int(asi++)]);
|
||||
savw = AvatarManager.avatarViewList[sfsUserId];
|
||||
if(savw == null)
|
||||
{
|
||||
DebugUtility.debugTrace("ERROR: invalid avatar worldview savw:" + savw + " sfsUserId:" + sfsUserId + " data:" + data);
|
||||
return;
|
||||
}
|
||||
savw.setActivePet(0,0,0,"");
|
||||
if(savw.getChildAt(0).hasOwnProperty("onbottom1"))
|
||||
{
|
||||
ftci = savw.numChildren - 1;
|
||||
while(ftci > 0)
|
||||
{
|
||||
ftcdo = savw.getChildAt(ftci);
|
||||
if(ftcdo is MovieClip && MovieClip(ftcdo).hasOwnProperty("isTransformTop"))
|
||||
{
|
||||
endTransformAnim(MovieClip(ftcdo));
|
||||
break;
|
||||
}
|
||||
ftci--;
|
||||
}
|
||||
endTransformAnim(savw.getChildAt(0) as MovieClip);
|
||||
}
|
||||
if(_asTransformVec == null)
|
||||
{
|
||||
DebugUtility.debugTrace("ERROR: invalid AvatarSwitch state _asTransformTopMHVec:" + " data:" + data);
|
||||
return;
|
||||
}
|
||||
asTransformTop = new MediaHelper();
|
||||
asTransformTop.init(savw.roomType == Utility.ENVIRO_LAND ? uint(ASTRANSFORM_MEDIA_ID_TOP) : uint(ASTRANSFORM_OCEAN_MEDIA_ID_TOP),asTransformMediaHelper,[savw,data]);
|
||||
_asTransformVec.push(asTransformTop);
|
||||
asTransformBtm = new MediaHelper();
|
||||
asTransformBtm.init(savw.roomType == Utility.ENVIRO_LAND ? uint(ASTRANSFORM_MEDIA_ID_BOTTOM) : uint(ASTRANSFORM_OCEAN_MEDIA_ID_BOTTOM),asTransformMediaHelper,[savw]);
|
||||
_asTransformVec.push(asTransformBtm);
|
||||
if(sfsUserId == playerSfsUserId)
|
||||
{
|
||||
GuiManager.setSwapBtnGray(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUtility.debugTrace("switch error!!!");
|
||||
RoomXtCommManager.isSwitching = false;
|
||||
if(!QuestManager.isInPrivateAdventureState)
|
||||
{
|
||||
GuiManager.setSwapBtnGray(false);
|
||||
}
|
||||
if(_switchIdx != activeAvatarIdx)
|
||||
{
|
||||
_switchIdx = activeAvatarIdx;
|
||||
}
|
||||
}
|
||||
if(_switchCallback != null)
|
||||
{
|
||||
_switchCallback(success,true);
|
||||
if(!success)
|
||||
{
|
||||
_switchCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function myAvatarListCallback(slotFlags:int) : void
|
||||
{
|
||||
availSlotFlags = slotFlags;
|
||||
}
|
||||
|
||||
public static function removeAvatar(removeIdx:int, removeAvatarCallback:Function) : void
|
||||
{
|
||||
if(removeIdx < 0 || removeIdx >= avatars.length)
|
||||
{
|
||||
throw new Error("Invalid removeIdx:" + removeIdx);
|
||||
}
|
||||
if(avatars.length <= 1)
|
||||
{
|
||||
throw new Error("Tried to remove avatar when less than 2 were left!");
|
||||
}
|
||||
_removeCallback = removeAvatarCallback;
|
||||
_removeIdx = removeIdx;
|
||||
AvatarXtCommManager.requestAvatarKill([avatars[removeIdx].perUserAvId],avatarKillResponse);
|
||||
}
|
||||
|
||||
public static function avatarKillResponse(success:Boolean, newGemBalance:int) : void
|
||||
{
|
||||
var removedAvInvId:int = 0;
|
||||
var isCurrSlotAvailable:Boolean = false;
|
||||
var ui:UserInfo = null;
|
||||
if(success)
|
||||
{
|
||||
isCurrSlotAvailable = isSlotAvailable(_removeIdx);
|
||||
removedAvInvId = int(AvatarXtCommManager.avSlotInfo[avatars[_removeIdx].perUserAvId].avInvId);
|
||||
ui = gMainFrame.userInfo.getUserInfoByUserName(avatars[_removeIdx].userName);
|
||||
ui.allItemsInUseOff(avatars[_removeIdx].perUserAvId);
|
||||
AvatarXtCommManager.avSlotInfo[avatars[_removeIdx].perUserAvId].avInvId = null;
|
||||
avatars[_removeIdx] = null;
|
||||
}
|
||||
if(_removeCallback != null)
|
||||
{
|
||||
_removeCallback(success,_removeIdx,removedAvInvId,newGemBalance,isCurrSlotAvailable);
|
||||
}
|
||||
_removeIdx = -1;
|
||||
}
|
||||
|
||||
public static function chooseTwo(switchIdxs:Array, aoCallback:Function) : void
|
||||
{
|
||||
_switchIdx = avatars[switchIdxs[0]].enviroTypeFlag == 2 ? int(switchIdxs[1]) : int(switchIdxs[0]);
|
||||
_secondChosenAvtIdx = -1;
|
||||
var switchInvIds:Array = [];
|
||||
switchInvIds[0] = AvatarXtCommManager.avSlotInfo[avatars[switchIdxs[0]].perUserAvId].avInvId;
|
||||
if(switchIdxs[1] != null && Boolean(AvatarSwitch.avatars[switchIdxs[1]]))
|
||||
{
|
||||
switchInvIds[1] = AvatarXtCommManager.avSlotInfo[avatars[switchIdxs[1]].perUserAvId].avInvId;
|
||||
_secondChosenAvtIdx = switchIdxs[1];
|
||||
}
|
||||
AvatarXtCommManager.requestAvatarOrdain(switchInvIds,aoCallback);
|
||||
}
|
||||
|
||||
private static function asTransformMediaHelper(mc:MovieClip) : void
|
||||
{
|
||||
if(!mc.hasOwnProperty("mediaHelper"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var mh:MediaHelper = MediaHelper(mc.mediaHelper);
|
||||
var mhid:int = mh.id;
|
||||
if(mhid != ASTRANSFORM_MEDIA_ID_TOP && mhid != ASTRANSFORM_MEDIA_ID_BOTTOM && mhid != ASTRANSFORM_OCEAN_MEDIA_ID_TOP && mhid != ASTRANSFORM_OCEAN_MEDIA_ID_BOTTOM)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mc.addEventListener(Event.ENTER_FRAME,transformEnterFrameHandler);
|
||||
var savw:AvatarView = AvatarView((mc.passback as Array)[0]);
|
||||
if(mhid == ASTRANSFORM_MEDIA_ID_TOP || mhid == ASTRANSFORM_OCEAN_MEDIA_ID_TOP)
|
||||
{
|
||||
mc.data = (mc.passback as Array)[1] as Array;
|
||||
DebugUtility.debugTrace("got top media for sfsUserId:" + int(mc.data[3]));
|
||||
mc.isTransformTop = true;
|
||||
savw.addChild(mc);
|
||||
_asTransformVec.splice(_asTransformVec.indexOf(mh),1);
|
||||
}
|
||||
else
|
||||
{
|
||||
mc.isTransformBottom = true;
|
||||
savw.addChildAt(mc,0);
|
||||
_asTransformVec.splice(_asTransformVec.indexOf(mh),1);
|
||||
}
|
||||
mc.gotoAndPlay(1);
|
||||
mc.mediaHelper.destroy();
|
||||
delete mc.mediaHelper;
|
||||
delete mc.passback;
|
||||
}
|
||||
|
||||
private static function transformEnterFrameHandler(e:Event) : void
|
||||
{
|
||||
var data:Array = null;
|
||||
var asi:int = 0;
|
||||
var sfsUserId:int = 0;
|
||||
var selfSwitch:Boolean = false;
|
||||
var sav:Avatar = null;
|
||||
var otherAvatar:Avatar = null;
|
||||
var avatarWorldView:AvatarWorldView = null;
|
||||
var sai:AvatarInfo = null;
|
||||
var newAvatar:Avatar = null;
|
||||
var petInvId:int = 0;
|
||||
var myPet:Object = null;
|
||||
var newAvInfo:AvatarInfo = null;
|
||||
var lBits:int = 0;
|
||||
var uBits:int = 0;
|
||||
var eBits:int = 0;
|
||||
var petName:String = null;
|
||||
var questLevel:int = 0;
|
||||
var currPet:Object = null;
|
||||
var ble:BuddyEvent = null;
|
||||
var savw:AvatarWorldView = null;
|
||||
var etavw:AvatarWorldView = null;
|
||||
var tf:MovieClip = MovieClip(e.target);
|
||||
if(tf.parent == null || AvatarView(tf.parent).avatarData == null)
|
||||
{
|
||||
endTransformAnim(tf);
|
||||
return;
|
||||
}
|
||||
if(tf.currentFrameLabel != null)
|
||||
{
|
||||
DebugUtility.debugTrace("entered frame:" + tf.currentFrameLabel + " on transform effect for sfsUserId:" + AvatarView(tf.parent).userId);
|
||||
}
|
||||
if(tf.currentFrameLabel == "hideAvatar")
|
||||
{
|
||||
AvatarView(tf.parent).hideAvatar();
|
||||
if(tf.hasOwnProperty("data"))
|
||||
{
|
||||
data = tf.data;
|
||||
asi = 3;
|
||||
sfsUserId = int(data[int(asi++)]);
|
||||
selfSwitch = Boolean(sfsUserId == playerSfsUserId);
|
||||
sav = AvatarManager.getAvatarBySfsUserId(sfsUserId);
|
||||
if(selfSwitch)
|
||||
{
|
||||
otherAvatar = avatars[_switchIdx];
|
||||
otherAvatar.perUserAvId = sav.perUserAvId;
|
||||
otherAvatar.avTypeId = sav.avTypeId;
|
||||
otherAvatar.copyColors(sav.colors);
|
||||
otherAvatar.avName = sav.avName;
|
||||
otherAvatar.cloneShownAccFromAvatar(sav);
|
||||
AvatarManager.clearPlayerSplashColor();
|
||||
}
|
||||
sav.removeAllItems();
|
||||
sav.perUserAvId = int(data[int(asi++)]);
|
||||
sav.avTypeId = int(data[int(asi++)]);
|
||||
sav.setColors(uint(data[int(asi++)]),uint(data[int(asi++)]),uint(data[int(asi++)]));
|
||||
sav.avName = data[int(asi++)];
|
||||
if(sav.userName == gMainFrame.userInfo.myUserName && gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(sav.userName,sav.perUserAvId) == null)
|
||||
{
|
||||
AvatarXtCommManager.requestADForAvatar(sav.perUserAvId,true,null,sav);
|
||||
}
|
||||
else
|
||||
{
|
||||
sai = new AvatarInfo();
|
||||
sai.perUserAvId = sav.perUserAvId;
|
||||
sai.avName = sav.avName;
|
||||
sai.userName = sav.userName;
|
||||
sai.colors = sav.colors.concat();
|
||||
sai.type = sav.avTypeId;
|
||||
}
|
||||
avatarWorldView = AvatarManager.getAvatarWorldViewBySfsUserId(sfsUserId);
|
||||
if(Boolean(avatarWorldView))
|
||||
{
|
||||
if(avatarWorldView.parent != null)
|
||||
{
|
||||
avatarWorldView.parent.removeChild(avatarWorldView);
|
||||
}
|
||||
if(Boolean(sav.enviroTypeFlag & 1 << Utility.ENVIRO_AIR))
|
||||
{
|
||||
avatarWorldView.x += AvatarManager.getAvatarLayer.x + AvatarManager.getAvatarLayer.parent.x - AvatarManager.getFlyingLayer.x;
|
||||
avatarWorldView.y += AvatarManager.getAvatarLayer.y + AvatarManager.getAvatarLayer.parent.y - AvatarManager.getFlyingLayer.y;
|
||||
AvatarManager.getFlyingLayer.addChild(avatarWorldView);
|
||||
}
|
||||
else
|
||||
{
|
||||
avatarWorldView.x -= AvatarManager.getAvatarLayer.x + AvatarManager.getAvatarLayer.parent.x - AvatarManager.getFlyingLayer.x;
|
||||
avatarWorldView.y -= AvatarManager.getAvatarLayer.y + AvatarManager.getAvatarLayer.parent.y - AvatarManager.getFlyingLayer.y;
|
||||
AvatarManager.getAvatarLayer.addChild(avatarWorldView);
|
||||
}
|
||||
}
|
||||
if(selfSwitch)
|
||||
{
|
||||
if((otherAvatar.enviroTypeFlag & 1 << Utility.ENVIRO_AIR) != (sav.enviroTypeFlag & 1 << Utility.ENVIRO_AIR))
|
||||
{
|
||||
RoomManagerWorld.instance.rebuildGrid();
|
||||
if(avatarWorldView == null && !(sav.enviroTypeFlag & 1 << Utility.ENVIRO_AIR) || Boolean(RoomManagerWorld.instance.collisionTestGrid(avatarWorldView.x,avatarWorldView.y)))
|
||||
{
|
||||
RoomManagerWorld.instance.teleportPlayerToDefault();
|
||||
}
|
||||
}
|
||||
gMainFrame.userInfo.myPerUserAvId = sav.perUserAvId;
|
||||
GuiManager.positionHudAvatar();
|
||||
newAvatar = avatars[activeAvatarIdx];
|
||||
avatars.splice(activeAvatarIdx,1);
|
||||
avatars.unshift(avatars[_switchIdx - 1]);
|
||||
avatars.splice(_switchIdx,1);
|
||||
if(_secondChosenAvtIdx != -1)
|
||||
{
|
||||
avatars.unshift(avatars[_secondChosenAvtIdx - 1]);
|
||||
avatars.splice(_secondChosenAvtIdx,1);
|
||||
}
|
||||
avatars.unshift(newAvatar);
|
||||
activeAvatarIdx = 0;
|
||||
_switchIdx = 0;
|
||||
_secondChosenAvtIdx = -1;
|
||||
petInvId = int(data[asi++]);
|
||||
myPet = PetManager.getMyPetByInvId(petInvId);
|
||||
if(Boolean(AvatarManager.playerAvatarWorldView))
|
||||
{
|
||||
avatarWorldView = AvatarManager.playerAvatarWorldView;
|
||||
avatarWorldView.setActivePet(Boolean(myPet) ? uint(myPet.lBits) : 0,Boolean(myPet) ? uint(myPet.uBits) : 0,Boolean(myPet) ? uint(myPet.eBits) : 0,Boolean(myPet) ? myPet.name : "");
|
||||
}
|
||||
PetManager.myActivePetInvId = petInvId;
|
||||
newAvInfo = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(sav.userName,sav.perUserAvId);
|
||||
if(Boolean(newAvInfo))
|
||||
{
|
||||
sai.questLevel = int(data[asi++]);
|
||||
sai.questHealthPercentage = newAvInfo.questHealthPercentage;
|
||||
sai.healthBase = newAvInfo.healthBase;
|
||||
sai.attackBase = newAvInfo.attackBase;
|
||||
sai.attackMax = newAvInfo.attackMax;
|
||||
sai.defenseBase = newAvInfo.defenseBase;
|
||||
sai.defenseMax = newAvInfo.defenseMax;
|
||||
gMainFrame.userInfo.setAvatarInfoByUsernamePerUserAvId(sav.perUserAvId,sai,true);
|
||||
sav.itemResponseIntegrate(gMainFrame.userInfo.getUserInfoByUserName(sav.userName).getPartialItemList(sav.avTypeId,true));
|
||||
avatarWorldView.updateNameBarLevelShape(sai.questLevel);
|
||||
}
|
||||
updateAvatarSlotIds();
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemXtCommManager.requestItemListForAvatar(null,sav,false,false);
|
||||
if(Boolean(AvatarManager.buddyCardAvatarView) && sav.userName == AvatarManager.buddyCardAvatarView.userName)
|
||||
{
|
||||
BuddyCard.updateCurrBuddyCardAvatar(sav);
|
||||
}
|
||||
lBits = int(data[int(asi++)]);
|
||||
uBits = int(data[int(asi++)]);
|
||||
eBits = int(data[int(asi++)]);
|
||||
petName = data[int(asi++)];
|
||||
questLevel = int(data[asi++]);
|
||||
avatarWorldView = AvatarManager.getAvatarWorldViewBySfsUserId(sfsUserId);
|
||||
if(Boolean(avatarWorldView))
|
||||
{
|
||||
avatarWorldView.setActivePet(lBits,uBits,eBits,petName);
|
||||
}
|
||||
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);
|
||||
sai.currPet = currPet;
|
||||
sai.questLevel = questLevel;
|
||||
gMainFrame.userInfo.setAvatarInfoByUsernamePerUserAvId(sav.perUserAvId,sai,true);
|
||||
avatarWorldView.updateNameBarLevelShape(sai.questLevel);
|
||||
ble = new BuddyEvent(BuddyEvent.BUDDY_CHANGED);
|
||||
ble.userName = sai.userName;
|
||||
BuddyManager.eventDispatcher.dispatchEvent(ble);
|
||||
}
|
||||
AvatarWorldView(tf.parent).setPos(tf.parent.x,tf.parent.y,false);
|
||||
delete tf.data;
|
||||
if(_switchCallback != null)
|
||||
{
|
||||
_switchCallback(true);
|
||||
_switchCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(tf.currentFrameLabel == "changeAvatar")
|
||||
{
|
||||
AvatarView(tf.parent).showAvatar();
|
||||
}
|
||||
else if(tf.currentFrameLabel == "tintOn")
|
||||
{
|
||||
savw = AvatarWorldView(tf.parent);
|
||||
if(savw.roomType == Utility.ENVIRO_LAND)
|
||||
{
|
||||
savw.setBlendColor(4290903190,7534606);
|
||||
}
|
||||
else
|
||||
{
|
||||
savw.setBlendColor(4294967295,16777107);
|
||||
}
|
||||
}
|
||||
else if(tf.currentFrameLabel == "tintOff")
|
||||
{
|
||||
etavw = AvatarWorldView(tf.parent);
|
||||
etavw.setBlendColor(0);
|
||||
etavw.setAlphaLevel(100);
|
||||
if(etavw.userId == playerSfsUserId)
|
||||
{
|
||||
AvatarManager.clearPlayerSplashColor();
|
||||
}
|
||||
}
|
||||
else if(tf.currentFrame == tf.totalFrames)
|
||||
{
|
||||
endTransformAnim(tf);
|
||||
}
|
||||
}
|
||||
|
||||
private static function endTransformAnim(tf:MovieClip) : void
|
||||
{
|
||||
var etavw:AvatarView = AvatarView(tf.parent);
|
||||
if(tf.parent != null && etavw.avatarData != null)
|
||||
{
|
||||
DebugUtility.debugTrace("ending one of two transitions for sfsUserId:" + etavw.userId);
|
||||
}
|
||||
tf.removeEventListener(Event.ENTER_FRAME,transformEnterFrameHandler);
|
||||
var s:SoundTransform = tf.soundTransform;
|
||||
s.volume = 0;
|
||||
tf.soundTransform = s;
|
||||
tf.gotoAndStop(1);
|
||||
RoomXtCommManager.isSwitching = false;
|
||||
if(etavw.userName == gMainFrame.userInfo.myUserName && !QuestManager.isInPrivateAdventureState)
|
||||
{
|
||||
GuiManager.setSwapBtnGray(false);
|
||||
}
|
||||
if(tf.parent != null)
|
||||
{
|
||||
tf.parent.removeChild(tf);
|
||||
}
|
||||
}
|
||||
|
||||
private static function updateAvatarSlotIds() : void
|
||||
{
|
||||
var currAvtSlotInfo:Object = null;
|
||||
var ourAvatarSlotInfo:Object = AvatarXtCommManager.avSlotInfo;
|
||||
for(var i:int = 0; i < avatars.length; i++)
|
||||
{
|
||||
if(Boolean(avatars[i]))
|
||||
{
|
||||
currAvtSlotInfo = ourAvatarSlotInfo[avatars[i].perUserAvId];
|
||||
if(Boolean(currAvtSlotInfo))
|
||||
{
|
||||
currAvtSlotInfo.slotId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,343 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.graphics.LayerAnim;
|
||||
import flash.display.Sprite;
|
||||
import flash.filters.ColorMatrixFilter;
|
||||
import item.Item;
|
||||
|
||||
public class AvatarView extends Sprite
|
||||
{
|
||||
|
||||
protected var _layerAnim:LayerAnim;
|
||||
|
||||
protected var _avatar:Avatar;
|
||||
|
||||
public var avTypeChangedCallback:Function;
|
||||
|
||||
private var _isOffScreen:Boolean;
|
||||
|
||||
private var _holdAnimId:int;
|
||||
|
||||
private var _lastAnimToHappen:int;
|
||||
|
||||
public function AvatarView()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function set lastAnimToHappen(lastAnimId:int) : void
|
||||
{
|
||||
this._lastAnimToHappen = lastAnimId;
|
||||
}
|
||||
|
||||
public function get lastAnimToHappen() : int
|
||||
{
|
||||
return this._lastAnimToHappen;
|
||||
}
|
||||
|
||||
public function set holdAnimId(inAnimId:int) : void
|
||||
{
|
||||
this._holdAnimId = inAnimId;
|
||||
}
|
||||
|
||||
public function init(avatar:Avatar, avTypeCallback:Function = null) : void
|
||||
{
|
||||
this._holdAnimId = 0;
|
||||
this._avatar = avatar;
|
||||
this._avatar.addEventListener(AvatarEvent.AVATAR_CHANGED,this.avatarChanged,false,0,true);
|
||||
this.avTypeChangedCallback = avTypeCallback;
|
||||
this._layerAnim = LayerAnim.getNew();
|
||||
this._layerAnim.avDefId = this._avatar.avTypeId;
|
||||
if(Boolean(this._avatar.colors))
|
||||
{
|
||||
this._layerAnim.layers = this.setLayerHelper();
|
||||
}
|
||||
this.addChild(this._layerAnim.bitmap);
|
||||
}
|
||||
|
||||
public function destroy(destroyAvatar:Boolean = false) : void
|
||||
{
|
||||
if(destroyAvatar && Boolean(this._avatar))
|
||||
{
|
||||
this._avatar.removeEventListener(AvatarEvent.AVATAR_CHANGED,this.avatarChanged);
|
||||
this._avatar.destroy();
|
||||
this._avatar = null;
|
||||
}
|
||||
this.avTypeChangedCallback = null;
|
||||
LayerAnim.destroy(this._layerAnim);
|
||||
this._layerAnim = null;
|
||||
}
|
||||
|
||||
public function resetAvatar(rAv:Avatar) : void
|
||||
{
|
||||
if(Boolean(this._avatar) && this._avatar.hasEventListener(AvatarEvent.AVATAR_CHANGED))
|
||||
{
|
||||
this._avatar.removeEventListener(AvatarEvent.AVATAR_CHANGED,this.avatarChanged);
|
||||
}
|
||||
this._avatar = rAv;
|
||||
this._avatar.addEventListener(AvatarEvent.AVATAR_CHANGED,this.avatarChanged,false,0,true);
|
||||
if(Boolean(this._layerAnim))
|
||||
{
|
||||
this._layerAnim.avDefId = this._avatar.avTypeId;
|
||||
if(Boolean(this._avatar.colors))
|
||||
{
|
||||
this._layerAnim.layers = this.setLayerHelper();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function isValid() : Boolean
|
||||
{
|
||||
return this._layerAnim != null;
|
||||
}
|
||||
|
||||
public function hideAvatar() : void
|
||||
{
|
||||
if(this._layerAnim != null)
|
||||
{
|
||||
this._layerAnim.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function showAvatar() : void
|
||||
{
|
||||
if(this._layerAnim != null)
|
||||
{
|
||||
this._layerAnim.visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function set isOffScreen(value:Boolean) : void
|
||||
{
|
||||
this._isOffScreen = value;
|
||||
}
|
||||
|
||||
public function get isOffScreen() : Boolean
|
||||
{
|
||||
return this._isOffScreen;
|
||||
}
|
||||
|
||||
public function pauseAnim(b:Boolean) : void
|
||||
{
|
||||
this._layerAnim.pause = b;
|
||||
}
|
||||
|
||||
public function advanceFrame() : void
|
||||
{
|
||||
++this._layerAnim.frame;
|
||||
}
|
||||
|
||||
public function get frame() : int
|
||||
{
|
||||
return this._layerAnim.frame;
|
||||
}
|
||||
|
||||
public function set frame(f:int) : void
|
||||
{
|
||||
this._layerAnim.frame = f;
|
||||
}
|
||||
|
||||
public function get flip() : Boolean
|
||||
{
|
||||
return this._layerAnim.hFlip;
|
||||
}
|
||||
|
||||
public function get animId() : int
|
||||
{
|
||||
return this._layerAnim.animId;
|
||||
}
|
||||
|
||||
protected function avatarChanged(evt:AvatarEvent) : void
|
||||
{
|
||||
if(Boolean(this._layerAnim))
|
||||
{
|
||||
if(this._layerAnim.avDefId != this._avatar.avTypeId)
|
||||
{
|
||||
this._layerAnim.avDefId = this._avatar.avTypeId;
|
||||
if(this.avTypeChangedCallback != null)
|
||||
{
|
||||
this.avTypeChangedCallback(this);
|
||||
}
|
||||
}
|
||||
this._layerAnim.layers = this.setLayerHelper();
|
||||
}
|
||||
}
|
||||
|
||||
protected function setLayerHelper() : Array
|
||||
{
|
||||
var avInfo:AvatarInfo = null;
|
||||
var tempItems:Array = null;
|
||||
var items:Array = null;
|
||||
if(Boolean(this._avatar.inventoryBodyMod) && Boolean(this._avatar.inventoryBodyMod.itemArray) && this._avatar.inventoryBodyMod.itemArray.length >= 1)
|
||||
{
|
||||
items = this._avatar.inventoryBodyMod.itemArray.concat(this._avatar.inventoryClothing.itemArray.concat());
|
||||
}
|
||||
else
|
||||
{
|
||||
avInfo = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(this._avatar.userName,this._avatar.perUserAvId);
|
||||
if(Boolean(avInfo))
|
||||
{
|
||||
tempItems = avInfo.getItems(true);
|
||||
if(Boolean(tempItems))
|
||||
{
|
||||
items = tempItems;
|
||||
}
|
||||
}
|
||||
}
|
||||
return AvatarUtility.layerArrayForItemsAndColors(items,this._avatar.colors,this._avatar.perUserAvId);
|
||||
}
|
||||
|
||||
public function playAnim(animId:int, hFlip:Boolean = false, mode:int = 0, callback:Function = null) : void
|
||||
{
|
||||
var needToChangeLayers:Boolean = false;
|
||||
var accItems:Array = null;
|
||||
var accItemsLength:int = 0;
|
||||
var ntci:int = 0;
|
||||
var layerArray:Array = null;
|
||||
var shownItems:Array = null;
|
||||
var obj:Object = null;
|
||||
var colors:Array = null;
|
||||
var color:uint = 0;
|
||||
var showItem:Item = null;
|
||||
if(Boolean(this._layerAnim) && Boolean(this._layerAnim.visible) && (this._holdAnimId == 0 || animId == this._holdAnimId))
|
||||
{
|
||||
if(!this._isOffScreen)
|
||||
{
|
||||
needToChangeLayers = false;
|
||||
accItems = this._avatar.accShownItems;
|
||||
if(!this._layerAnim.layers)
|
||||
{
|
||||
needToChangeLayers = true;
|
||||
}
|
||||
else if(this._layerAnim.layers.length != accItems.length)
|
||||
{
|
||||
needToChangeLayers = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
accItemsLength = int(accItems.length);
|
||||
for(ntci = 0; ntci < accItemsLength; ntci++)
|
||||
{
|
||||
if(this._layerAnim.layers.indexOf(accItems[ntci].accId) == -1)
|
||||
{
|
||||
needToChangeLayers = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(needToChangeLayers)
|
||||
{
|
||||
layerArray = [];
|
||||
shownItems = accItems;
|
||||
colors = this._avatar.colors;
|
||||
for each(showItem in shownItems)
|
||||
{
|
||||
if(showItem.getInUse(this._avatar.perUserAvId))
|
||||
{
|
||||
if(showItem.layerId == 1)
|
||||
{
|
||||
color = uint(colors[0]);
|
||||
}
|
||||
else if(showItem.layerId == 2)
|
||||
{
|
||||
color = uint(colors[1]);
|
||||
}
|
||||
else if(showItem.layerId == 3)
|
||||
{
|
||||
color = uint(colors[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
color = showItem.color;
|
||||
}
|
||||
obj = {
|
||||
"l":showItem.accId,
|
||||
"c":color
|
||||
};
|
||||
layerArray.push(obj);
|
||||
}
|
||||
}
|
||||
this._layerAnim.layers = layerArray;
|
||||
}
|
||||
this._layerAnim.hFlip = hFlip;
|
||||
this._layerAnim.playAnim(animId,mode,callback);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._lastAnimToHappen = animId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function reloadItemsFromCache() : void
|
||||
{
|
||||
var allItems:Array = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(this._avatar.userName,this._avatar.perUserAvId).getItems(true);
|
||||
this._avatar.itemResponseIntegrate(allItems);
|
||||
}
|
||||
|
||||
public function preloadAnims(anims:Array, callback:Function = null) : void
|
||||
{
|
||||
this._layerAnim.preload(anims,callback);
|
||||
}
|
||||
|
||||
public function blackOut() : void
|
||||
{
|
||||
var matrix:Array = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0];
|
||||
this._layerAnim.bitmap.filters = [new ColorMatrixFilter(matrix)];
|
||||
}
|
||||
|
||||
public function get avatarData() : Avatar
|
||||
{
|
||||
return this._avatar;
|
||||
}
|
||||
|
||||
public function get userName() : String
|
||||
{
|
||||
if(this._avatar != null)
|
||||
{
|
||||
return this._avatar.userName;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public function get userId() : int
|
||||
{
|
||||
if(this._avatar == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return this._avatar.sfsUserId;
|
||||
}
|
||||
|
||||
public function get avTypeId() : int
|
||||
{
|
||||
return this._avatar.avTypeId;
|
||||
}
|
||||
|
||||
public function get perUserAvId() : int
|
||||
{
|
||||
return this._avatar.perUserAvId;
|
||||
}
|
||||
|
||||
public function get inventoryBodyModItems() : Array
|
||||
{
|
||||
return this._avatar.inventoryBodyMod.itemArray;
|
||||
}
|
||||
|
||||
public function get inventoryClothingItems() : Array
|
||||
{
|
||||
return this._avatar.inventoryClothing.itemArray;
|
||||
}
|
||||
|
||||
public function setAvtColors(colors:Array) : void
|
||||
{
|
||||
this._avatar.colors = colors;
|
||||
}
|
||||
|
||||
public function get avName() : String
|
||||
{
|
||||
return this._avatar.avName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
package avatar
|
||||
{
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Loader;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Shape;
|
||||
import flash.display.Sprite;
|
||||
import flash.geom.Matrix;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class AvatarViewExt_Splash
|
||||
{
|
||||
|
||||
private static const SHADOW_X_OFFSET:int = -100;
|
||||
|
||||
private static const SHADOW_Y_OFFSET:int = -20;
|
||||
|
||||
private static const Shadow:Class = AvatarViewExt_Splash_Shadow;
|
||||
|
||||
private static const WaterSplashSWF:Class = AvatarViewExt_Splash_WaterSplashSWF;
|
||||
|
||||
private const _constSplash:ByteArray = new WaterSplashSWF();
|
||||
|
||||
private var _mask:Shape;
|
||||
|
||||
private var _shadow:Bitmap;
|
||||
|
||||
private var _splash:Loader;
|
||||
|
||||
private var _parent:Sprite;
|
||||
|
||||
private var _maskLayer:DisplayObject;
|
||||
|
||||
private var _bLastSplashVolume:Boolean;
|
||||
|
||||
private var _bSplashInProgress:Boolean;
|
||||
|
||||
private var _lastSplashLiquid:String;
|
||||
|
||||
private var _shadowChildIndex:int;
|
||||
|
||||
public function AvatarViewExt_Splash(parent:Sprite, layerBitmap:DisplayObject)
|
||||
{
|
||||
super();
|
||||
this._parent = parent;
|
||||
this._bSplashInProgress = false;
|
||||
this._bLastSplashVolume = false;
|
||||
this.createShadow();
|
||||
this.createMask(layerBitmap);
|
||||
this._parent.addChild(layerBitmap);
|
||||
this.createSplash();
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
if(Boolean(this._shadow) && this._shadow.parent != null)
|
||||
{
|
||||
this._shadow.parent.removeChild(this._shadow);
|
||||
this._shadow = null;
|
||||
}
|
||||
if(Boolean(this._splash))
|
||||
{
|
||||
this._parent.removeChild(this._splash);
|
||||
this._splash.unloadAndStop();
|
||||
this._splash = null;
|
||||
}
|
||||
if(Boolean(this._mask))
|
||||
{
|
||||
this._parent.removeChild(this._mask);
|
||||
this._mask = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function showShadow(flag:Boolean = true) : void
|
||||
{
|
||||
this._shadow.visible = flag;
|
||||
}
|
||||
|
||||
private function createShadow() : void
|
||||
{
|
||||
this._shadow = new Shadow();
|
||||
this._shadow.x = SHADOW_X_OFFSET;
|
||||
this._shadow.y = SHADOW_Y_OFFSET;
|
||||
this._parent.addChild(this._shadow);
|
||||
}
|
||||
|
||||
private function createMask(maskLayer:DisplayObject) : void
|
||||
{
|
||||
var x:Number = NaN;
|
||||
var y:Number = NaN;
|
||||
this._maskLayer = maskLayer;
|
||||
this._mask = new Shape();
|
||||
this._parent.addChild(this._mask);
|
||||
this._mask.graphics.lineStyle();
|
||||
this._mask.graphics.beginFill(16777215,1);
|
||||
x = -150;
|
||||
y = -275;
|
||||
this._mask.graphics.moveTo(x,y);
|
||||
this._mask.graphics.lineTo(x + 245,y);
|
||||
this._mask.graphics.lineTo(x + 245,y + 235);
|
||||
this._mask.graphics.curveTo(x + 122.5,y + 260,x,y + 235);
|
||||
this._mask.graphics.lineTo(x,y);
|
||||
this._mask.graphics.endFill();
|
||||
this._maskLayer.mask = null;
|
||||
this._mask.visible = false;
|
||||
}
|
||||
|
||||
private function createSplash() : void
|
||||
{
|
||||
this._splash = new Loader();
|
||||
this._splash.loadBytes(this._constSplash);
|
||||
this._splash.x = -18;
|
||||
this._splash.y = -28;
|
||||
this._parent.addChild(this._splash);
|
||||
this._splash.visible = false;
|
||||
}
|
||||
|
||||
public function flipSplash(b:Boolean) : void
|
||||
{
|
||||
var matrix:Matrix = this._shadow.transform.matrix;
|
||||
if(b)
|
||||
{
|
||||
if(matrix.a != -1)
|
||||
{
|
||||
matrix.scale(-1,1);
|
||||
this._shadow.transform.matrix = matrix;
|
||||
matrix = this._splash.content.transform.matrix;
|
||||
matrix.scale(-1,1);
|
||||
this._splash.content.transform.matrix = matrix;
|
||||
}
|
||||
}
|
||||
else if(matrix.a == -1)
|
||||
{
|
||||
matrix.scale(-1,1);
|
||||
this._shadow.transform.matrix = matrix;
|
||||
matrix = this._splash.content.transform.matrix;
|
||||
matrix.scale(-1,1);
|
||||
this._splash.content.transform.matrix = matrix;
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(bInSplashVolume:Boolean, bIsSplashAnim:Boolean, splashLiquid:String, inAir:Boolean) : void
|
||||
{
|
||||
if(Boolean(this._shadow))
|
||||
{
|
||||
if(inAir)
|
||||
{
|
||||
if(this._shadow.parent != null)
|
||||
{
|
||||
this._shadowChildIndex = this._shadow.parent.getChildIndex(this._shadow);
|
||||
this._shadow.parent.removeChild(this._shadow);
|
||||
}
|
||||
}
|
||||
else if(this._shadow.parent == null)
|
||||
{
|
||||
this._parent.addChildAt(this._shadow,this._shadowChildIndex);
|
||||
}
|
||||
}
|
||||
var splashMC:MovieClip = MovieClip(this._splash.content);
|
||||
if(Boolean(splashMC))
|
||||
{
|
||||
if(splashLiquid == "ice" || splashLiquid == "fire" || splashLiquid == "ghost")
|
||||
{
|
||||
bInSplashVolume = false;
|
||||
}
|
||||
if(bInSplashVolume)
|
||||
{
|
||||
splashMC.setState(bIsSplashAnim ? 1 : 2);
|
||||
}
|
||||
else if(splashMC.currentFrame == 1 && this._splash.visible == true)
|
||||
{
|
||||
this._splash.visible = false;
|
||||
}
|
||||
if(bInSplashVolume != this._bLastSplashVolume || splashLiquid != this._lastSplashLiquid)
|
||||
{
|
||||
splashMC.setLiquid(splashLiquid);
|
||||
this._bLastSplashVolume = bInSplashVolume;
|
||||
this._lastSplashLiquid = splashLiquid;
|
||||
this.showMask(bInSplashVolume);
|
||||
if(bInSplashVolume)
|
||||
{
|
||||
if(this._splash.visible == false)
|
||||
{
|
||||
this._splash.visible = true;
|
||||
}
|
||||
splashMC.setState(bIsSplashAnim ? 1 : 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
splashMC.setState(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function showMask(show:Boolean = true) : void
|
||||
{
|
||||
if(show)
|
||||
{
|
||||
this._maskLayer.mask = this._mask;
|
||||
this.showShadow(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._maskLayer.mask = null;
|
||||
this.showShadow(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package avatar
|
||||
{
|
||||
import mx.core.BitmapAsset;
|
||||
|
||||
[ExcludeClass]
|
||||
[Embed(source="/_assets/4_avatar.AvatarViewExt_Splash_Shadow.png")]
|
||||
public class AvatarViewExt_Splash_Shadow extends BitmapAsset
|
||||
{
|
||||
|
||||
public function AvatarViewExt_Splash_Shadow()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package avatar
|
||||
{
|
||||
import mx.core.ByteArrayAsset;
|
||||
|
||||
[ExcludeClass]
|
||||
[Embed(source="/_assets/6_avatar.AvatarViewExt_Splash_WaterSplashSWF.bin", mimeType="application/octet-stream")]
|
||||
public class AvatarViewExt_Splash_WaterSplashSWF extends ByteArrayAsset
|
||||
{
|
||||
|
||||
public function AvatarViewExt_Splash_WaterSplashSWF()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,828 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.client.SFClient;
|
||||
import com.sbi.client.SFEvent;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.loader.FileServerEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.Dictionary;
|
||||
import item.Item;
|
||||
import item.ItemXtCommManager;
|
||||
import loader.DefPacksDefHelper;
|
||||
import pet.PetManager;
|
||||
|
||||
public class AvatarXtCommManager
|
||||
{
|
||||
|
||||
public static var avSlotInfo:Object;
|
||||
|
||||
private static var _adAvatarQueue:Array;
|
||||
|
||||
private static var _agQueue:Dictionary;
|
||||
|
||||
private static var _agsQueue:Dictionary;
|
||||
|
||||
private static var _avatarCreateResponse:Function;
|
||||
|
||||
private static var _avatarUpdateResponse:Function;
|
||||
|
||||
private static var _avatarPaintResponse:Function;
|
||||
|
||||
private static var _avatarRemoveResponse:Function;
|
||||
|
||||
private static var _avatarListResponse:Function;
|
||||
|
||||
private static var _getAvatarByUsername:Function;
|
||||
|
||||
private static var _buddyCardUpdateDropDownHandler:Function;
|
||||
|
||||
private static var _avatarInfoCallback:Function;
|
||||
|
||||
private static var _abCallback:Function;
|
||||
|
||||
private static var _asCallback:Function;
|
||||
|
||||
private static var _aaCallback:Function;
|
||||
|
||||
private static var _alCallback:Function;
|
||||
|
||||
private static var _handleCreateAvatarData:Function;
|
||||
|
||||
private static var _akCallback:Function;
|
||||
|
||||
private static var _aoCallback:Function;
|
||||
|
||||
private static var _photoTakeCallback:Function;
|
||||
|
||||
private static var _avatarsInRoom:Object;
|
||||
|
||||
private static var _gameAvatarAdCallback:Function;
|
||||
|
||||
public function AvatarXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init(initACResponse:Function = null, initAUResponse:Function = null, initAPResponse:Function = null, initARResponse:Function = null, initALResponse:Function = null, initAvatarsInRoom:Object = null, initGetAvatarByUserName:Function = null, initASResponse:Function = null, initBuddyCardUpdateDropDown:Function = null) : void
|
||||
{
|
||||
_avatarCreateResponse = initACResponse;
|
||||
_avatarUpdateResponse = initAUResponse;
|
||||
_avatarPaintResponse = initAPResponse;
|
||||
_avatarRemoveResponse = initARResponse;
|
||||
_avatarListResponse = initALResponse;
|
||||
_getAvatarByUsername = initGetAvatarByUserName;
|
||||
_asCallback = initASResponse;
|
||||
_buddyCardUpdateDropDownHandler = initBuddyCardUpdateDropDown;
|
||||
_adAvatarQueue = [];
|
||||
avSlotInfo = new Object();
|
||||
_agQueue = new Dictionary(false);
|
||||
_agsQueue = new Dictionary(false);
|
||||
_avatarsInRoom = initAvatarsInRoom;
|
||||
XtReplyDemuxer.addModule(handleXtReply,"a");
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
_adAvatarQueue = null;
|
||||
XtReplyDemuxer.removeModule(handleXtReply);
|
||||
}
|
||||
|
||||
public static function requestAvatarMake(initHandleCreateAvatarData:Function) : void
|
||||
{
|
||||
_handleCreateAvatarData = initHandleCreateAvatarData;
|
||||
gMainFrame.server.setXtObject_Str("am",[],gMainFrame.server.isWorldZone);
|
||||
}
|
||||
|
||||
public static function requestAvatarInfo(setAvatarInfoCallback:Function) : void
|
||||
{
|
||||
var dpdh:DefPacksDefHelper = null;
|
||||
_avatarInfoCallback = setAvatarInfoCallback;
|
||||
if(gMainFrame.userInfo.avtDefsCached)
|
||||
{
|
||||
if(_avatarInfoCallback != null)
|
||||
{
|
||||
_avatarInfoCallback();
|
||||
_avatarInfoCallback = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dpdh = new DefPacksDefHelper();
|
||||
dpdh.init(DefPacksDefHelper.DEF_AVATAR,avatarInfoResponse,null,FileServerEvent.AMF3_TYPE);
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_AVATAR] = dpdh;
|
||||
}
|
||||
}
|
||||
|
||||
public static function requestADForAvatar(getPerUserAvId:int, requestItemList:Boolean, getAvDataCallback:Function, getAvDataAvatar:Avatar) : void
|
||||
{
|
||||
_adAvatarQueue.push({
|
||||
"a":getAvDataAvatar,
|
||||
"c":(requestItemList ? null : getAvDataCallback)
|
||||
});
|
||||
var wasItemListAlreadyRequested:Boolean = gMainFrame.userInfo.myUserName == getAvDataAvatar.userName ? ItemXtCommManager.hasRequestedFullItemList : true;
|
||||
var cachedInfo:AvatarInfo = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(getAvDataAvatar.userName,getPerUserAvId);
|
||||
if(Boolean(cachedInfo) && cachedInfo.type != -1)
|
||||
{
|
||||
avatarDataResponseIntegrate([cachedInfo.perUserAvId,cachedInfo.avName,cachedInfo.userName,cachedInfo.type,cachedInfo.colors[0],cachedInfo.colors[1],cachedInfo.colors[2]]);
|
||||
if(requestItemList)
|
||||
{
|
||||
if(getAvDataAvatar == null)
|
||||
{
|
||||
throw new Error("requestAvatarData got requestItemList=true but getAvDataAvatar=null!");
|
||||
}
|
||||
if(getAvDataAvatar.userName != gMainFrame.userInfo.myUserName)
|
||||
{
|
||||
ItemXtCommManager.requestItemListForAvatar(getAvDataCallback,getAvDataAvatar,!wasItemListAlreadyRequested);
|
||||
}
|
||||
else
|
||||
{
|
||||
getAvDataCallback();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(requestItemList)
|
||||
{
|
||||
ItemXtCommManager.insertIntoILAvatarQueue(getPerUserAvId,getAvDataCallback,getAvDataAvatar);
|
||||
}
|
||||
sendAvatarDataRequest([getAvDataAvatar.userName,getPerUserAvId,requestItemList ? (wasItemListAlreadyRequested ? "2" : "1") : "0"]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function requestAvatarList(alParams:Array, alCallback:Function = null) : void
|
||||
{
|
||||
_alCallback = alCallback;
|
||||
gMainFrame.server.setXtObject_Str("al",alParams,gMainFrame.server.isWorldZone);
|
||||
}
|
||||
|
||||
public static function requestAvatarBuy(abCallback:Function) : void
|
||||
{
|
||||
_abCallback = abCallback;
|
||||
gMainFrame.server.setXtObject_Str("ab",[]);
|
||||
}
|
||||
|
||||
public static function requestAvatarSwitch(asParams:Array) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("as",asParams);
|
||||
}
|
||||
|
||||
public static function requestAvatarAdd(aaParams:Array, aaCallback:Function) : void
|
||||
{
|
||||
_aaCallback = aaCallback;
|
||||
gMainFrame.server.setXtObject_Str("aa",aaParams,gMainFrame.server.isWorldZone);
|
||||
}
|
||||
|
||||
public static function requestAvatarShopBuy(asbParams:Array, asbCallback:Function) : void
|
||||
{
|
||||
_aaCallback = asbCallback;
|
||||
gMainFrame.server.setXtObject_Str("asb",asbParams,gMainFrame.server.isWorldZone);
|
||||
}
|
||||
|
||||
public static function requestAvatarKill(akParams:Array, akCallback:Function) : void
|
||||
{
|
||||
_akCallback = akCallback;
|
||||
gMainFrame.server.setXtObject_Str("ak",akParams);
|
||||
}
|
||||
|
||||
public static function requestAvatarOrdain(avIdxs:Array, aoCallback:Function) : void
|
||||
{
|
||||
_aoCallback = aoCallback;
|
||||
gMainFrame.server.setXtObject_Str("ao",avIdxs);
|
||||
}
|
||||
|
||||
public static function requestAvatarGet(userName:String, callback:Function, isPlayerSearchLookup:Boolean = false) : void
|
||||
{
|
||||
_agQueue[userName.toLowerCase()] = callback;
|
||||
gMainFrame.server.setXtObject_Str("ag",[userName,isPlayerSearchLookup ? "1" : "0"]);
|
||||
}
|
||||
|
||||
public static function requestAvatarGetBySfsId(sfsUserId:int, callback:Function) : void
|
||||
{
|
||||
_agsQueue[sfsUserId] = callback;
|
||||
gMainFrame.server.setXtObject_Str("ags",[sfsUserId,"0"]);
|
||||
}
|
||||
|
||||
public static function requestColorChange(colors:Array, nameBarColor:int, requestColorsCallback:Function = null) : void
|
||||
{
|
||||
if(requestColorsCallback != null)
|
||||
{
|
||||
_avatarPaintResponse = requestColorsCallback;
|
||||
}
|
||||
gMainFrame.server.setXtObject_Str("ap",[colors[0],colors[1],colors[2],nameBarColor],gMainFrame.server.isWorldZone);
|
||||
}
|
||||
|
||||
public static function setGameAvatarAdCallback(callback:Function) : void
|
||||
{
|
||||
_gameAvatarAdCallback = callback;
|
||||
}
|
||||
|
||||
public static function sendAvatarPendingFlagsUpdate(bit:int) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("af",[bit]);
|
||||
gMainFrame.userInfo.pendingFlags |= 1 << bit;
|
||||
}
|
||||
|
||||
public static function sendAvatarPhotoTakeCheck(callback:Function) : void
|
||||
{
|
||||
_photoTakeCallback = callback;
|
||||
gMainFrame.server.setXtObject_Str("apc",[]);
|
||||
}
|
||||
|
||||
public static function sendAvatarPhotoTake(callback:Function) : void
|
||||
{
|
||||
_photoTakeCallback = callback;
|
||||
gMainFrame.server.setXtObject_Str("apb",[]);
|
||||
}
|
||||
|
||||
private static function sendAvatarDataRequest(radParams:Array) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("ad",radParams,gMainFrame.server.isWorldZone);
|
||||
}
|
||||
|
||||
public static function handleXtReply(evt:SFEvent) : void
|
||||
{
|
||||
if(!evt.status)
|
||||
{
|
||||
DebugUtility.debugTrace("ERROR: AvatarXtCommManager handleXtReply was called with bad evt.status:" + evt.status);
|
||||
return;
|
||||
}
|
||||
var data:Array = evt.obj;
|
||||
switch(data[0])
|
||||
{
|
||||
case "au":
|
||||
if(_avatarUpdateResponse != null)
|
||||
{
|
||||
_avatarUpdateResponse(data);
|
||||
}
|
||||
break;
|
||||
case "ad":
|
||||
avatarDataResponse(data);
|
||||
break;
|
||||
case "ac":
|
||||
if(_avatarCreateResponse != null)
|
||||
{
|
||||
_avatarCreateResponse(data);
|
||||
}
|
||||
break;
|
||||
case "ap":
|
||||
if(_avatarPaintResponse != null)
|
||||
{
|
||||
_avatarPaintResponse(data);
|
||||
}
|
||||
break;
|
||||
case "ag":
|
||||
avatarGetResponse(data);
|
||||
break;
|
||||
case "ar":
|
||||
if(_avatarRemoveResponse != null)
|
||||
{
|
||||
_avatarRemoveResponse(data);
|
||||
}
|
||||
break;
|
||||
case "al":
|
||||
avatarListResponse(data);
|
||||
break;
|
||||
case "ab":
|
||||
avatarBuyResponse(data);
|
||||
break;
|
||||
case "as":
|
||||
avatarSwitchResponse(data);
|
||||
break;
|
||||
case "aa":
|
||||
avatarAddResponse(data);
|
||||
break;
|
||||
case "ak":
|
||||
avatarKillResponse(data);
|
||||
break;
|
||||
case "am":
|
||||
_handleCreateAvatarData(data);
|
||||
break;
|
||||
case "ao":
|
||||
avatarOrdainResponse(data);
|
||||
break;
|
||||
case "apb":
|
||||
case "apc":
|
||||
if(_photoTakeCallback != null)
|
||||
{
|
||||
_photoTakeCallback(data);
|
||||
_photoTakeCallback = null;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error("AvatarXtCommManager illegal data:" + data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarInfoResponse(df:DefPacksDefHelper) : void
|
||||
{
|
||||
var numTypes:int = 0;
|
||||
var currObj:Object = null;
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_AVATAR] = null;
|
||||
var data:Object = df.def;
|
||||
var avtDefs:Object = new Object();
|
||||
var avtOffsets:Array = [];
|
||||
for each(currObj in data)
|
||||
{
|
||||
avtOffsets[int(currObj.id)] = new Point(currObj.x,currObj.y);
|
||||
avtDefs[int(currObj.id)] = {
|
||||
"colorLayer1":uint(currObj.colorLayer1),
|
||||
"colorLayer2":uint(currObj.colorLayer2),
|
||||
"colorLayer3":uint(currObj.colorLayer3),
|
||||
"defPattern":int(currObj.basePatternId),
|
||||
"defEyes":int(currObj.baseEyesId),
|
||||
"isMemOnly":Boolean(currObj.membersOnly == "1"),
|
||||
"enviroTypeFlag":int(currObj.enviroTypeFlags),
|
||||
"cost":int(currObj.cost),
|
||||
"titleStrRef":int(currObj.titleStrRef),
|
||||
"availability":int(currObj.availability),
|
||||
"attackItemRefId":int(currObj.attackItemRefId),
|
||||
"iconMediaId":int(currObj.iconMediaRefId),
|
||||
"status":int(currObj.status)
|
||||
};
|
||||
}
|
||||
if(!gMainFrame.userInfo.avtDefsCached)
|
||||
{
|
||||
gMainFrame.setAvatarOffsets(avtOffsets);
|
||||
gMainFrame.userInfo.setAvatarDefs(avtDefs);
|
||||
}
|
||||
var dpdh:DefPacksDefHelper = new DefPacksDefHelper();
|
||||
dpdh.init(DefPacksDefHelper.DEF_LAYER,liDefPacksResponse,null,FileServerEvent.AMF3_TYPE);
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_LAYER] = dpdh;
|
||||
}
|
||||
|
||||
private static function liDefPacksResponse(df:DefPacksDefHelper) : void
|
||||
{
|
||||
var currObj:Object = null;
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_LAYER] = null;
|
||||
var data:Object = df.def;
|
||||
var layerInfoObj:Object = {};
|
||||
for each(currObj in data)
|
||||
{
|
||||
layerInfoObj[int(currObj.id)] = int(currObj.layerId);
|
||||
}
|
||||
gMainFrame.layerInfo = layerInfoObj;
|
||||
if(_avatarInfoCallback != null)
|
||||
{
|
||||
_avatarInfoCallback();
|
||||
_avatarInfoCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarDataResponse(data:Array) : void
|
||||
{
|
||||
var isForSelf:Boolean = false;
|
||||
var attackBase:int = 0;
|
||||
var attackMax:int = 0;
|
||||
var defenseBase:int = 0;
|
||||
var defenseMax:int = 0;
|
||||
var healthBase:int = 0;
|
||||
var lBits:int = 0;
|
||||
var uBits:int = 0;
|
||||
var eBits:int = 0;
|
||||
var avatarInfo:AvatarInfo = null;
|
||||
var avInfo:AvatarInfo = null;
|
||||
var setCacheInfo:UserInfo = null;
|
||||
var avList:Array = null;
|
||||
var adri:int = 2;
|
||||
var adUserName:String = data[adri++];
|
||||
var adNameBarData:int = int(data[adri++]);
|
||||
var currEnviroType:int = int(data[adri++]);
|
||||
var userNameModerationFlag:int = int(data[adri++]);
|
||||
var adPerUserAvId:int = int(data[adri++]);
|
||||
var adType:int = int(data[adri++]);
|
||||
var adColor1:uint = uint(data[adri++]);
|
||||
var adColor2:uint = uint(data[adri++]);
|
||||
var adColor3:uint = uint(data[adri++]);
|
||||
var adAvName:String = data[adri++];
|
||||
var questLevel:int = int(data[adri++]);
|
||||
var adAvInvId:int = -1;
|
||||
var landPetInvId:int = 0;
|
||||
var oceanPetInvId:int = 0;
|
||||
var questXp:int = 0;
|
||||
var questXPPercentage:int = 0;
|
||||
var petName:String = "";
|
||||
if(adUserName == gMainFrame.userInfo.myUserName)
|
||||
{
|
||||
isForSelf = true;
|
||||
adAvInvId = int(data[adri++]);
|
||||
landPetInvId = int(data[adri++]);
|
||||
oceanPetInvId = int(data[adri++]);
|
||||
attackBase = int(data[adri++]);
|
||||
attackMax = int(data[adri++]);
|
||||
defenseBase = int(data[adri++]);
|
||||
defenseMax = int(data[adri++]);
|
||||
healthBase = int(data[adri++]);
|
||||
}
|
||||
else
|
||||
{
|
||||
lBits = int(data[adri++]);
|
||||
uBits = int(data[adri++]);
|
||||
eBits = int(data[adri++]);
|
||||
petName = data[adri++];
|
||||
}
|
||||
var userInfo:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(adUserName);
|
||||
if(Boolean(userInfo))
|
||||
{
|
||||
for each(avInfo in userInfo.avList)
|
||||
{
|
||||
if(avInfo.perUserAvId == adPerUserAvId)
|
||||
{
|
||||
avatarInfo = avInfo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
userInfo.nameBarData = adNameBarData;
|
||||
userInfo.userNameModeratedFlag = userNameModerationFlag;
|
||||
}
|
||||
var currPet:Object = {
|
||||
"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);
|
||||
if(Boolean(avatarInfo))
|
||||
{
|
||||
avatarInfo.avName = adAvName;
|
||||
avatarInfo.userName = adUserName;
|
||||
avatarInfo.type = adType;
|
||||
avatarInfo.colors = [adColor1,adColor2,adColor3];
|
||||
avatarInfo.currEnviroType = currEnviroType;
|
||||
avatarInfo.questLevel = questLevel;
|
||||
avatarInfo.currPet = currPet;
|
||||
if(isForSelf)
|
||||
{
|
||||
if(adAvInvId >= 0)
|
||||
{
|
||||
avSlotInfo[avatarInfo.perUserAvId].avInvId = adAvInvId;
|
||||
}
|
||||
avatarInfo.landPetInvId = landPetInvId;
|
||||
avatarInfo.oceanPetInvId = oceanPetInvId;
|
||||
avatarInfo.questXp = questXp;
|
||||
avatarInfo.healthBase = healthBase;
|
||||
avatarInfo.attackBase = attackBase;
|
||||
avatarInfo.attackMax = attackMax;
|
||||
avatarInfo.defenseBase = defenseBase;
|
||||
avatarInfo.defenseMax = defenseMax;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
avatarInfo = new AvatarInfo();
|
||||
avatarInfo.init(adPerUserAvId,adAvName,adUserName,adType,[adColor1,adColor2,adColor3],0,currPet);
|
||||
avatarInfo.questLevel = questLevel;
|
||||
if(isForSelf)
|
||||
{
|
||||
if(adAvInvId >= 0)
|
||||
{
|
||||
avSlotInfo[avatarInfo.perUserAvId] = {
|
||||
"slotId":-1,
|
||||
"avInvId":adAvInvId
|
||||
};
|
||||
}
|
||||
avatarInfo.landPetInvId = landPetInvId;
|
||||
avatarInfo.oceanPetInvId = oceanPetInvId;
|
||||
avatarInfo.questXp = questXp;
|
||||
avatarInfo.healthBase = healthBase;
|
||||
avatarInfo.attackBase = attackBase;
|
||||
avatarInfo.attackMax = attackMax;
|
||||
avatarInfo.defenseBase = defenseBase;
|
||||
avatarInfo.defenseMax = defenseMax;
|
||||
}
|
||||
if(Boolean(userInfo))
|
||||
{
|
||||
userInfo.addAvatarToList(avatarInfo);
|
||||
userInfo.nameBarData = adNameBarData;
|
||||
userInfo.userNameModeratedFlag = userNameModerationFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
setCacheInfo = new UserInfo();
|
||||
avList = new Array();
|
||||
avList[avatarInfo.perUserAvId] = avatarInfo;
|
||||
setCacheInfo.init(adUserName,avList,avatarInfo.perUserAvId,1,userNameModerationFlag);
|
||||
setCacheInfo.nameBarData = adNameBarData;
|
||||
gMainFrame.userInfo.setUserInfoByUserName(adUserName,setCacheInfo);
|
||||
}
|
||||
}
|
||||
avatarDataResponseIntegrate([adPerUserAvId,adAvName,adUserName,adType,adColor1,adColor2,adColor3]);
|
||||
}
|
||||
|
||||
private static function avatarDataResponseIntegrate(newAvData:Array) : void
|
||||
{
|
||||
var avtNotInQueueButInRoom:Boolean = false;
|
||||
var i:int = 0;
|
||||
var userName:String = null;
|
||||
var avt:Avatar = null;
|
||||
var di:int = 0;
|
||||
var dataAvatar:Avatar = null;
|
||||
var loadDataAvatarResult:Function = null;
|
||||
if(Boolean(_adAvatarQueue) && _adAvatarQueue.length > 0)
|
||||
{
|
||||
for(i = 0; i < _adAvatarQueue.length; i++)
|
||||
{
|
||||
if(_adAvatarQueue[i].a.perUserAvId == newAvData[0])
|
||||
{
|
||||
dataAvatar = _adAvatarQueue[i].a;
|
||||
loadDataAvatarResult = _adAvatarQueue[i].c;
|
||||
_adAvatarQueue.splice(i,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(Boolean(_avatarsInRoom))
|
||||
{
|
||||
userName = newAvData[2];
|
||||
if(_getAvatarByUsername != null)
|
||||
{
|
||||
avt = _getAvatarByUsername(userName);
|
||||
}
|
||||
if(Boolean(avt))
|
||||
{
|
||||
dataAvatar = avt;
|
||||
avtNotInQueueButInRoom = true;
|
||||
}
|
||||
}
|
||||
if(Boolean(dataAvatar))
|
||||
{
|
||||
di = 0;
|
||||
dataAvatar.perUserAvId = newAvData[di++];
|
||||
dataAvatar.avName = newAvData[di++];
|
||||
dataAvatar.userName = newAvData[di++];
|
||||
dataAvatar.avTypeId = int(newAvData[di++]);
|
||||
dataAvatar.setColors(uint(newAvData[di++]),uint(newAvData[di++]),uint(newAvData[di++]));
|
||||
if(!avtNotInQueueButInRoom)
|
||||
{
|
||||
if(loadDataAvatarResult != null)
|
||||
{
|
||||
loadDataAvatarResult();
|
||||
loadDataAvatarResult = null;
|
||||
}
|
||||
if(_gameAvatarAdCallback != null)
|
||||
{
|
||||
_gameAvatarAdCallback(dataAvatar);
|
||||
}
|
||||
}
|
||||
_buddyCardUpdateDropDownHandler(dataAvatar.userName);
|
||||
}
|
||||
else if(loadDataAvatarResult != null)
|
||||
{
|
||||
DebugUtility.debugTrace("calling loadDataAvatarResult even though dataAvatar was null...");
|
||||
loadDataAvatarResult();
|
||||
loadDataAvatarResult = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarGetResponse(data:Array) : void
|
||||
{
|
||||
var accountType:int = 0;
|
||||
var isGuide:Boolean = false;
|
||||
var perUserAvId:int = 0;
|
||||
var nameBarData:int = 0;
|
||||
var avType:int = 0;
|
||||
var colors:Array = null;
|
||||
var avName:String = null;
|
||||
var eyeDefId:int = 0;
|
||||
var pattDefId:int = 0;
|
||||
var questLevel:int = 0;
|
||||
var numClothingItems:int = 0;
|
||||
var sfsUserId:int = 0;
|
||||
var userNameModeratedFlag:int = 0;
|
||||
var lBits:int = 0;
|
||||
var uBits:int = 0;
|
||||
var eBits:int = 0;
|
||||
var petName:String = null;
|
||||
var numBodyModItems:int = 0;
|
||||
var items:Array = null;
|
||||
var i:int = 0;
|
||||
var currPet:Object = null;
|
||||
var userInfo:UserInfo = null;
|
||||
var avInfo:AvatarInfo = null;
|
||||
var aItem:Item = null;
|
||||
var avList:Array = null;
|
||||
var j:int = 2;
|
||||
var userName:String = data[j++];
|
||||
var avatarGetStatus:int = int(data[j++]);
|
||||
var onlineStatus:int = avatarGetStatus == 0 ? SFClient.STATUS_OFFLINE_ACTIVE : (avatarGetStatus == 1 ? SFClient.STATUS_ONLINE : (avatarGetStatus == 2 ? SFClient.STATUS_OFFLINE_ARCHIVED : SFClient.STATUS_OFFLINE_UNKNOWN));
|
||||
if(avatarGetStatus <= 1)
|
||||
{
|
||||
accountType = int(data[j++]);
|
||||
isGuide = data[j++] == "1";
|
||||
perUserAvId = int(data[j++]);
|
||||
nameBarData = int(data[j++]);
|
||||
avType = int(data[j++]);
|
||||
colors = new Array(3);
|
||||
colors[0] = uint(data[j++]);
|
||||
colors[1] = uint(data[j++]);
|
||||
colors[2] = uint(data[j++]);
|
||||
avName = data[j++];
|
||||
eyeDefId = int(data[j++]);
|
||||
pattDefId = int(data[j++]);
|
||||
questLevel = int(data[j++]);
|
||||
numClothingItems = int(data[j++]);
|
||||
sfsUserId = int(data[j++]);
|
||||
userNameModeratedFlag = int(data[j++]);
|
||||
lBits = int(data[j++]);
|
||||
uBits = int(data[j++]);
|
||||
eBits = int(data[j++]);
|
||||
petName = data[j++];
|
||||
numBodyModItems = pattDefId > 0 ? 3 : 2;
|
||||
items = new Array(numClothingItems + numBodyModItems);
|
||||
i = 0;
|
||||
items[i++] = ItemXtCommManager.getBodyModFromDefId(1,perUserAvId,true);
|
||||
items[i++] = ItemXtCommManager.getBodyModFromDefId(eyeDefId,perUserAvId,true);
|
||||
if(pattDefId > 0)
|
||||
{
|
||||
items[i++] = ItemXtCommManager.getBodyModFromDefId(pattDefId,perUserAvId,true);
|
||||
}
|
||||
for(DebugUtility.debugTrace("avatarGetResponse userName:" + userName + " numClothingItems:" + numClothingItems + " numBodyModItems:" + numBodyModItems + " pattDefId:" + pattDefId); i < numClothingItems + numBodyModItems; )
|
||||
{
|
||||
aItem = new Item();
|
||||
aItem.init(int(data[j++]),i,uint(data[j++]));
|
||||
aItem.setInUse(perUserAvId,true);
|
||||
items[i] = aItem;
|
||||
i++;
|
||||
}
|
||||
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);
|
||||
userInfo = gMainFrame.userInfo.getUserInfoByUserName(userName);
|
||||
avInfo = new AvatarInfo();
|
||||
avInfo.init(perUserAvId,avName,userName,avType,colors,0,currPet,0,0,0,questLevel);
|
||||
if(!userInfo)
|
||||
{
|
||||
avList = new Array(1);
|
||||
avList[perUserAvId] = avInfo;
|
||||
userInfo = new UserInfo();
|
||||
userInfo.init(userName,avList,perUserAvId,accountType);
|
||||
}
|
||||
else
|
||||
{
|
||||
userInfo.currPerUserAvId = perUserAvId;
|
||||
userInfo.accountType = accountType;
|
||||
userInfo.addAvatarToList(avInfo);
|
||||
}
|
||||
userInfo.userNameModeratedFlag = userNameModeratedFlag;
|
||||
userInfo.nameBarData = nameBarData;
|
||||
userInfo.isGuide = isGuide;
|
||||
gMainFrame.userInfo.setUserInfoByUserName(userName,userInfo);
|
||||
}
|
||||
var lcUserName:String = userName.toLowerCase();
|
||||
if(Boolean(_agQueue[lcUserName]))
|
||||
{
|
||||
_agQueue[lcUserName](userName,avatarGetStatus < 3,onlineStatus);
|
||||
delete _agQueue[lcUserName];
|
||||
}
|
||||
if(Boolean(_agsQueue[sfsUserId]))
|
||||
{
|
||||
_agsQueue[sfsUserId](userName,avatarGetStatus < 3,onlineStatus,sfsUserId);
|
||||
delete _agsQueue[sfsUserId];
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarListResponse(data:Array) : void
|
||||
{
|
||||
var isForSelf:Boolean = false;
|
||||
var userName:String = null;
|
||||
var numAvNames:int = 0;
|
||||
var avList:Array = null;
|
||||
var currPerUserAvId:int = 0;
|
||||
var userInfo:UserInfo = null;
|
||||
var j:int = 0;
|
||||
var setUserInfo:UserInfo = null;
|
||||
var perUserAvId:int = 0;
|
||||
var avSlotIdx:int = 0;
|
||||
var avName:String = null;
|
||||
var avInfo:AvatarInfo = null;
|
||||
var al:int = 2;
|
||||
var numUserNames:int = int(data[al++]);
|
||||
var slotsAvailFlags:int = -1;
|
||||
for(var i:int = 0; i < numUserNames; i++)
|
||||
{
|
||||
userName = data[al++];
|
||||
if(userName == gMainFrame.server.userName)
|
||||
{
|
||||
isForSelf = true;
|
||||
slotsAvailFlags = int(data[al++]);
|
||||
}
|
||||
numAvNames = int(data[al++]);
|
||||
avList = [];
|
||||
userInfo = gMainFrame.userInfo.getUserInfoByUserName(userName);
|
||||
for(j = 0; j < numAvNames; j++)
|
||||
{
|
||||
perUserAvId = int(data[al++]);
|
||||
if(j == 0)
|
||||
{
|
||||
currPerUserAvId = perUserAvId;
|
||||
}
|
||||
avSlotIdx = int(data[al++]);
|
||||
avName = data[al++];
|
||||
if(Boolean(userInfo))
|
||||
{
|
||||
avInfo = userInfo.getAvatarInfoByPerUserAvId(perUserAvId);
|
||||
if(!avInfo)
|
||||
{
|
||||
avInfo = new AvatarInfo();
|
||||
avInfo.init(perUserAvId,avName,userName);
|
||||
}
|
||||
avList[perUserAvId] = avInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
avInfo = new AvatarInfo();
|
||||
avInfo.init(perUserAvId,avName,userName);
|
||||
avList[perUserAvId] = avInfo;
|
||||
}
|
||||
if(isForSelf)
|
||||
{
|
||||
avSlotInfo[perUserAvId] = {
|
||||
"slotId":j,
|
||||
"avInvId":avSlotIdx
|
||||
};
|
||||
}
|
||||
}
|
||||
setUserInfo = new UserInfo();
|
||||
if(Boolean(userInfo))
|
||||
{
|
||||
userInfo.avList = avList;
|
||||
userInfo.currPerUserAvId = currPerUserAvId;
|
||||
setUserInfo = userInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
setUserInfo.init(userName,avList,currPerUserAvId);
|
||||
}
|
||||
gMainFrame.userInfo.setUserInfoByUserName(userName,setUserInfo);
|
||||
}
|
||||
if(userName != gMainFrame.server.userName)
|
||||
{
|
||||
if(_avatarListResponse != null)
|
||||
{
|
||||
_avatarListResponse();
|
||||
}
|
||||
}
|
||||
if(_alCallback != null)
|
||||
{
|
||||
if(slotsAvailFlags >= 0)
|
||||
{
|
||||
_alCallback(slotsAvailFlags);
|
||||
}
|
||||
else
|
||||
{
|
||||
_alCallback(numUserNames == -1);
|
||||
}
|
||||
_alCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarBuyResponse(data:Array) : void
|
||||
{
|
||||
if(_abCallback != null)
|
||||
{
|
||||
_abCallback(Boolean(int(data[2])));
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarSwitchResponse(data:Array) : void
|
||||
{
|
||||
if(_asCallback != null)
|
||||
{
|
||||
_asCallback(data);
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarAddResponse(data:Array) : void
|
||||
{
|
||||
if(_aaCallback != null)
|
||||
{
|
||||
_aaCallback(int(data[2]),int(data[3]),int(data[4]));
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarKillResponse(data:Array) : void
|
||||
{
|
||||
if(_akCallback != null)
|
||||
{
|
||||
_akCallback(Boolean(int(data[2])),int(data[3]));
|
||||
}
|
||||
}
|
||||
|
||||
private static function avatarOrdainResponse(data:Array) : void
|
||||
{
|
||||
if(_aoCallback != null)
|
||||
{
|
||||
_aoCallback(Boolean(int(data[2])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package avatar
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
|
||||
public interface INewAvatar
|
||||
{
|
||||
|
||||
function screenInitCallback(param1:MovieClip) : void;
|
||||
|
||||
function get playSound() : Boolean;
|
||||
|
||||
function newAvatarData(param1:int, param2:String, param3:Array, param4:Function, param5:Boolean = false) : void;
|
||||
|
||||
function hideConnectingMsg() : void;
|
||||
|
||||
function logInForCreateAvatarData() : void;
|
||||
|
||||
function nameTypeScreenDone() : void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,869 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.graphics.LayerAnim;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.filters.GlowFilter;
|
||||
import flash.geom.Point;
|
||||
import flash.text.TextField;
|
||||
import flash.text.TextFieldAutoSize;
|
||||
import flash.text.TextFormat;
|
||||
import gskinner.motion.GTween;
|
||||
import gskinner.motion.easing.Linear;
|
||||
import item.Item;
|
||||
import item.ItemXtCommManager;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
import quest.QuestManager;
|
||||
import room.RoomManagerWorld;
|
||||
|
||||
public class NPCView extends Sprite
|
||||
{
|
||||
|
||||
public static const NPC_STATE_LOADING:int = -2;
|
||||
|
||||
public static const NPC_STATE_LOADED:int = -1;
|
||||
|
||||
public static const NPC_STATE_IDLE:int = 0;
|
||||
|
||||
public static const NPC_STATE_MOVE:int = 1;
|
||||
|
||||
public static const NPC_STATE_ATTACK:int = 2;
|
||||
|
||||
public static const NPC_STATE_RECOIL:int = 3;
|
||||
|
||||
public static const NPC_STATE_DEATH:int = 4;
|
||||
|
||||
public static const NPC_STATE_TREASURE_APPEAR:int = 5;
|
||||
|
||||
public static const NPC_STATE_TREASURE_OPEN:int = 6;
|
||||
|
||||
public static const NPC_STATE_TREASURE_DISAPPEAR:int = 7;
|
||||
|
||||
public static const NPC_STATE_DANCE:int = 8;
|
||||
|
||||
private var _npcDef:Object;
|
||||
|
||||
private var _npcMC:MovieClip;
|
||||
|
||||
private var _npcAvatarView:AvatarWorldView;
|
||||
|
||||
private var _playerId:int;
|
||||
|
||||
private var _namebar:NameBar;
|
||||
|
||||
private var _mediaHelperObj:MediaHelper;
|
||||
|
||||
private var _onLoadingCompleteCallback:Function;
|
||||
|
||||
private var _npcState:int;
|
||||
|
||||
private var _npcAngle:int;
|
||||
|
||||
private var _healthBar:MovieClip;
|
||||
|
||||
private var _hitText:TextField;
|
||||
|
||||
private var _hitTextTween:GTween;
|
||||
|
||||
private var _secondaryNpcMC:MovieClip;
|
||||
|
||||
public var _eye:MovieClip;
|
||||
|
||||
public var _beam:MovieClip;
|
||||
|
||||
public var _npcFacingSW:Boolean;
|
||||
|
||||
public function NPCView()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get npcState() : int
|
||||
{
|
||||
return this._npcState;
|
||||
}
|
||||
|
||||
public function get npcStateComplete() : Boolean
|
||||
{
|
||||
switch(this._npcState)
|
||||
{
|
||||
case NPC_STATE_LOADING:
|
||||
return false;
|
||||
case NPC_STATE_LOADED:
|
||||
return true;
|
||||
case NPC_STATE_TREASURE_APPEAR:
|
||||
case NPC_STATE_TREASURE_OPEN:
|
||||
case NPC_STATE_TREASURE_DISAPPEAR:
|
||||
return this._npcMC == null || Boolean(this._npcMC.finished);
|
||||
default:
|
||||
throw new Error("NPVView: npcStateComplete: Unsupported state");
|
||||
}
|
||||
}
|
||||
|
||||
public function get readyToLaunchAttack() : Boolean
|
||||
{
|
||||
if(this._npcState == NPC_STATE_ATTACK)
|
||||
{
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
if(this._npcMC.attacking == true)
|
||||
{
|
||||
this._npcMC.attacking = false;
|
||||
return true;
|
||||
}
|
||||
if(this._npcMC.hasOwnProperty("counterAttacking") && this._npcMC.counterAttacking == true)
|
||||
{
|
||||
this._npcMC.counterAttacking = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function get readyToAttack() : Boolean
|
||||
{
|
||||
var customCollisionPoints:Array = null;
|
||||
var colPointIndex:int = 0;
|
||||
var colPoint:Object = null;
|
||||
if(this._npcMC != null && this._npcMC.hasOwnProperty("getCustomCollisionPoints"))
|
||||
{
|
||||
customCollisionPoints = this._npcMC.getCustomCollisionPoints();
|
||||
if(customCollisionPoints != null)
|
||||
{
|
||||
for(colPointIndex = 0; colPointIndex < customCollisionPoints.length; colPointIndex++)
|
||||
{
|
||||
colPoint = customCollisionPoints[colPointIndex];
|
||||
if(colPoint.Type == 2)
|
||||
{
|
||||
return !this._npcMC.animActive && Boolean(this._npcMC.readyForAttack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(this._npcState != NPC_STATE_ATTACK && this._npcState != NPC_STATE_DEATH)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get isDead() : Boolean
|
||||
{
|
||||
if(this._npcState == NPC_STATE_DEATH && (this._npcMC == null || this._npcMC.animActive == false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get isDying() : Boolean
|
||||
{
|
||||
return this._npcState == NPC_STATE_DEATH;
|
||||
}
|
||||
|
||||
public function moveFaceAnim(inAngle:Number) : void
|
||||
{
|
||||
var animDir:int = 0;
|
||||
var animFlip:Boolean = false;
|
||||
if(Boolean(this._npcAvatarView))
|
||||
{
|
||||
animDir = 0;
|
||||
for(animFlip = false; inAngle < 0; )
|
||||
{
|
||||
inAngle += 360;
|
||||
}
|
||||
while(inAngle >= 360)
|
||||
{
|
||||
inAngle -= 360;
|
||||
}
|
||||
if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_LAND)
|
||||
{
|
||||
if(inAngle < 180)
|
||||
{
|
||||
if(inAngle < 35)
|
||||
{
|
||||
animDir = LayerAnim.AN_MOVE_NNE;
|
||||
}
|
||||
else if(inAngle < 70)
|
||||
{
|
||||
animDir = LayerAnim.AN_MOVE_NE;
|
||||
}
|
||||
else if(inAngle < 110)
|
||||
{
|
||||
animDir = LayerAnim.AN_MOVE_E;
|
||||
}
|
||||
else if(inAngle < 145)
|
||||
{
|
||||
animDir = LayerAnim.AN_MOVE_SE;
|
||||
}
|
||||
else
|
||||
{
|
||||
animDir = LayerAnim.AN_MOVE_SSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
animFlip = true;
|
||||
if(inAngle < 215)
|
||||
{
|
||||
animDir = LayerAnim.AN_MOVE_SSE;
|
||||
}
|
||||
else if(inAngle < 250)
|
||||
{
|
||||
animDir = LayerAnim.AN_MOVE_SE;
|
||||
}
|
||||
else if(inAngle < 290)
|
||||
{
|
||||
animDir = LayerAnim.AN_MOVE_E;
|
||||
}
|
||||
else if(inAngle < 325)
|
||||
{
|
||||
animDir = LayerAnim.AN_MOVE_NE;
|
||||
}
|
||||
else
|
||||
{
|
||||
animDir = LayerAnim.AN_MOVE_NNE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_OCEAN)
|
||||
{
|
||||
if(inAngle < 180)
|
||||
{
|
||||
animDir = LayerAnim.AN_SWIM_E;
|
||||
}
|
||||
else
|
||||
{
|
||||
animFlip = true;
|
||||
animDir = LayerAnim.AN_SWIM_E;
|
||||
}
|
||||
}
|
||||
this._npcAvatarView.playAnim(animDir,animFlip,LayerAnim.PLAY_LOOP__KEEP_CURRENT_FRAME);
|
||||
}
|
||||
}
|
||||
|
||||
public function setNpcState(inState:int, inAngle:Number = 0) : void
|
||||
{
|
||||
if(this._npcState != NPC_STATE_DEATH)
|
||||
{
|
||||
switch(inState)
|
||||
{
|
||||
case NPC_STATE_TREASURE_APPEAR:
|
||||
if(Boolean(this._npcMC))
|
||||
{
|
||||
this._npcMC.appear();
|
||||
this._npcState = inState;
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_TREASURE_OPEN:
|
||||
if(Boolean(this._npcMC))
|
||||
{
|
||||
this._npcMC.openChest();
|
||||
this._npcState = inState;
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_TREASURE_DISAPPEAR:
|
||||
if(Boolean(this._npcMC))
|
||||
{
|
||||
this._npcMC.disappear();
|
||||
this._npcState = inState;
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_DEATH:
|
||||
if(Boolean(this._npcMC))
|
||||
{
|
||||
this._npcState = inState;
|
||||
this._npcMC.noHealth();
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_IDLE:
|
||||
if(Boolean(this._npcMC))
|
||||
{
|
||||
if(this._npcMC.animActive == false)
|
||||
{
|
||||
this._npcState = inState;
|
||||
this._npcMC.idle(270);
|
||||
}
|
||||
if(this._npcMC.hasOwnProperty("getSortHeight"))
|
||||
{
|
||||
if(Boolean(this._npcMC.parent.parent))
|
||||
{
|
||||
this._npcMC.parent.parent.name = this._npcMC.getSortHeight();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(Boolean(this._npcAvatarView))
|
||||
{
|
||||
if(this._npcState != inState)
|
||||
{
|
||||
if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_LAND)
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_IDLE_SE,false,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
else if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_OCEAN)
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_FLOAT,false,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
this._npcState = inState;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_MOVE:
|
||||
if(this._npcAvatarView != null)
|
||||
{
|
||||
this._npcState = inState;
|
||||
if(this._npcAngle != inAngle)
|
||||
{
|
||||
this._npcAngle = inAngle;
|
||||
this.moveFaceAnim(this._npcAngle);
|
||||
}
|
||||
}
|
||||
else if(this._npcMC != null)
|
||||
{
|
||||
this._npcAngle = inAngle;
|
||||
if(this._npcMC.animActive == false)
|
||||
{
|
||||
this._npcState = inState;
|
||||
this._npcMC.moveCycle(this._npcAngle);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_ATTACK:
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
this._npcState = inState;
|
||||
this._npcAngle = inAngle;
|
||||
this._npcMC.attack(this._npcAngle);
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_RECOIL:
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
if(this._npcState != NPC_STATE_RECOIL || this._npcMC.hasOwnProperty("animActive") == false || this._npcMC.animActive == false)
|
||||
{
|
||||
if(this._npcState == NPC_STATE_IDLE || this._npcState == NPC_STATE_MOVE)
|
||||
{
|
||||
this._npcState = inState;
|
||||
}
|
||||
this._npcMC.recoil(this._npcAngle);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_DANCE:
|
||||
if(this._npcAvatarView != null)
|
||||
{
|
||||
this._npcState = inState;
|
||||
if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_LAND)
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_DANCE,false,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
else if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_OCEAN)
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_WATER_JIG,false,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get collisionZapRadius() : Number
|
||||
{
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
return this._npcMC.getCollisionRadius(0);
|
||||
}
|
||||
return 20;
|
||||
}
|
||||
|
||||
public function get collisionRadiusMoving() : Number
|
||||
{
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
if("getCollisionRadius" in this._npcMC)
|
||||
{
|
||||
return this._npcMC.getCollisionRadius(1);
|
||||
}
|
||||
}
|
||||
return 20;
|
||||
}
|
||||
|
||||
public function get collisionRadiusAttack() : Number
|
||||
{
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
if("getCollisionRadius" in this._npcMC)
|
||||
{
|
||||
return this._npcMC.getCollisionRadius(2);
|
||||
}
|
||||
}
|
||||
return 20;
|
||||
}
|
||||
|
||||
public function get collisionMovingPoint() : Point
|
||||
{
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
if("getCollisionPoint" in this._npcMC)
|
||||
{
|
||||
return this._npcMC.getCollisionPoint(1);
|
||||
}
|
||||
}
|
||||
return new Point(0,0);
|
||||
}
|
||||
|
||||
public function get collisionZapPoint() : Point
|
||||
{
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
if("getCollisionPoint" in this._npcMC)
|
||||
{
|
||||
return this._npcMC.getCollisionPoint(2);
|
||||
}
|
||||
}
|
||||
return new Point(0,0);
|
||||
}
|
||||
|
||||
public function get collisionPointAttack() : Point
|
||||
{
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
if("getCollisionPoint" in this._npcMC)
|
||||
{
|
||||
return this._npcMC.getCollisionPoint(0);
|
||||
}
|
||||
}
|
||||
return new Point(0,0);
|
||||
}
|
||||
|
||||
public function get avatar() : Avatar
|
||||
{
|
||||
if(this._npcAvatarView != null)
|
||||
{
|
||||
return this._npcAvatarView.avatarData;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get talkingHeadMediaId() : int
|
||||
{
|
||||
if(this._npcDef != null)
|
||||
{
|
||||
return this._npcDef.headMediaRefId;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function reset() : void
|
||||
{
|
||||
this._npcState = NPC_STATE_LOADING;
|
||||
}
|
||||
|
||||
public function init(npcDefId:int, playerId:int, namebarStrId:int = -1, hasHealthBar:Boolean = false, onLoadingCompleteCallback:Function = null) : void
|
||||
{
|
||||
var avt:Avatar = null;
|
||||
var itemsToUse:Array = null;
|
||||
var i:int = 0;
|
||||
var aiItem:Item = null;
|
||||
var index:int = 0;
|
||||
var colors:Array = null;
|
||||
var loadSelfAnims:Array = null;
|
||||
var text:String = null;
|
||||
this._npcFacingSW = false;
|
||||
this._npcState = NPC_STATE_LOADING;
|
||||
this._npcAngle = 0;
|
||||
this._npcDef = QuestManager.getNPCDef(npcDefId);
|
||||
this._playerId = playerId;
|
||||
this._onLoadingCompleteCallback = onLoadingCompleteCallback;
|
||||
this._hitText = new TextField();
|
||||
this._hitText.selectable = false;
|
||||
this._hitText.multiline = false;
|
||||
this._hitText.autoSize = TextFieldAutoSize.CENTER;
|
||||
this._hitText.visible = false;
|
||||
this._hitText.embedFonts = true;
|
||||
this._hitText.defaultTextFormat = new TextFormat("TikiIsland-Regular",36,4286945);
|
||||
this._hitText.filters = [new GlowFilter(0,1,3,3,10,2)];
|
||||
switch(this._npcDef.type)
|
||||
{
|
||||
case 0:
|
||||
this._mediaHelperObj = new MediaHelper();
|
||||
this._mediaHelperObj.init(this._npcDef.mediaRefId,this.onMediaLoaded);
|
||||
break;
|
||||
case 1:
|
||||
avt = new Avatar();
|
||||
avt.avName = "";
|
||||
avt.userName = "";
|
||||
this._npcAvatarView = new AvatarWorldView();
|
||||
this._npcAvatarView.initWorldView(avt,QuestManager._layerManager.room_chat,Utility.NON_MEMBER,true);
|
||||
avt.init(-1,avt.avName,this._npcDef.avatarRefId,[this._npcDef.baseColor,this._npcDef.patternColor,this._npcDef.eyesColor]);
|
||||
avt.itemResponseIntegrate(ItemXtCommManager.generateBodyModList(this._npcDef.avatarRefId,this._npcDef.patternItemRefId,this._npcDef.eyesItemRefId,false));
|
||||
if(namebarStrId > 0)
|
||||
{
|
||||
if(this._npcAvatarView != null && this._npcAvatarView.avatarData != null)
|
||||
{
|
||||
text = LocalizationManager.translateIdOnly(namebarStrId);
|
||||
this._npcAvatarView.avatarData.avName = text;
|
||||
this._npcAvatarView.avatarData.userName = text;
|
||||
if(this._npcAvatarView.nameBar != null)
|
||||
{
|
||||
this._npcAvatarView.nameBar.setAvName(text);
|
||||
this._npcAvatarView.nameBar.visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
itemsToUse = new Array();
|
||||
index = 100;
|
||||
for(i = 0; i < this._npcAvatarView.avatarData.inventoryBodyMod.itemArray.length; i++)
|
||||
{
|
||||
itemsToUse.push(this._npcAvatarView.avatarData.inventoryBodyMod.itemArray[i]);
|
||||
}
|
||||
if(this._npcDef.backItemRefId != 0)
|
||||
{
|
||||
aiItem = new Item();
|
||||
colors = ItemXtCommManager.getItemDef(this._npcDef.backItemRefId).colors;
|
||||
aiItem.init(this._npcDef.backItemRefId,index++,colors[Math.min(this._npcDef.backColor,colors.length - 1)],-1,-1);
|
||||
itemsToUse.push(aiItem);
|
||||
}
|
||||
if(this._npcDef.headItemRefId != 0)
|
||||
{
|
||||
aiItem = new Item();
|
||||
colors = ItemXtCommManager.getItemDef(this._npcDef.headItemRefId).colors;
|
||||
aiItem.init(this._npcDef.headItemRefId,index++,colors[Math.min(this._npcDef.headColor,colors.length - 1)],-1,-1);
|
||||
itemsToUse.push(aiItem);
|
||||
}
|
||||
if(this._npcDef.legItemRefId != 0)
|
||||
{
|
||||
aiItem = new Item();
|
||||
colors = ItemXtCommManager.getItemDef(this._npcDef.legItemRefId).colors;
|
||||
aiItem.init(this._npcDef.legItemRefId,index++,colors[Math.min(this._npcDef.legColor,colors.length - 1)],-1,-1);
|
||||
itemsToUse.push(aiItem);
|
||||
}
|
||||
if(this._npcDef.neckItemRefId != 0)
|
||||
{
|
||||
aiItem = new Item();
|
||||
colors = ItemXtCommManager.getItemDef(this._npcDef.neckItemRefId).colors;
|
||||
aiItem.init(this._npcDef.neckItemRefId,index++,colors[Math.min(this._npcDef.neckColor,colors.length - 1)],-1,-1);
|
||||
itemsToUse.push(aiItem);
|
||||
}
|
||||
if(this._npcDef.tailItemRefId != 0)
|
||||
{
|
||||
aiItem = new Item();
|
||||
colors = ItemXtCommManager.getItemDef(this._npcDef.tailItemRefId).colors;
|
||||
aiItem.init(this._npcDef.tailItemRefId,index++,colors[Math.min(this._npcDef.tailColor,colors.length - 1)],-1,-1);
|
||||
itemsToUse.push(aiItem);
|
||||
}
|
||||
this._npcAvatarView.avatarData.itemResponseIntegrate(itemsToUse);
|
||||
loadSelfAnims = new Array(15);
|
||||
if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_LAND)
|
||||
{
|
||||
loadSelfAnims[0] = LayerAnim.AN_IDLE_SE;
|
||||
loadSelfAnims[1] = LayerAnim.AN_MOVE_NNE;
|
||||
loadSelfAnims[2] = LayerAnim.AN_MOVE_NE;
|
||||
loadSelfAnims[3] = LayerAnim.AN_MOVE_E;
|
||||
loadSelfAnims[4] = LayerAnim.AN_MOVE_SE;
|
||||
loadSelfAnims[5] = LayerAnim.AN_MOVE_SSE;
|
||||
loadSelfAnims[6] = LayerAnim.AN_DANCE;
|
||||
loadSelfAnims[7] = LayerAnim.AN_SLEEP;
|
||||
loadSelfAnims[8] = LayerAnim.AN_HOP;
|
||||
}
|
||||
else if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_OCEAN)
|
||||
{
|
||||
loadSelfAnims[0] = LayerAnim.AN_FLOAT;
|
||||
loadSelfAnims[1] = LayerAnim.AN_SWIM_E;
|
||||
loadSelfAnims[2] = LayerAnim.AN_WATER_DIVE;
|
||||
loadSelfAnims[3] = LayerAnim.AN_WATER_PLAY;
|
||||
loadSelfAnims[4] = LayerAnim.AN_WATER_SPIN;
|
||||
loadSelfAnims[5] = LayerAnim.AN_WATER_JIG;
|
||||
loadSelfAnims[6] = LayerAnim.AN_WATER_POSE;
|
||||
}
|
||||
this._npcAvatarView.preloadAnims(loadSelfAnims,this.redrawCallback);
|
||||
}
|
||||
if(hasHealthBar)
|
||||
{
|
||||
this._healthBar = GETDEFINITIONBYNAME("NPCHealth");
|
||||
this._healthBar.x = -this._healthBar.width * 0.5;
|
||||
this._healthBar.y = 18;
|
||||
this._healthBar.hpBar.width = this._healthBar.hpEnemyBarContainer.width;
|
||||
addChild(this._healthBar);
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
if(Boolean(this._mediaHelperObj))
|
||||
{
|
||||
this._mediaHelperObj.destroy();
|
||||
this._mediaHelperObj = null;
|
||||
}
|
||||
if(Boolean(this._npcMC))
|
||||
{
|
||||
if(this._npcMC.hasOwnProperty("destroyPhantomNPC"))
|
||||
{
|
||||
this._npcMC.destroyPhantomNPC();
|
||||
}
|
||||
if(this._npcMC.parent != null)
|
||||
{
|
||||
this._npcMC.parent.removeChild(this._npcMC);
|
||||
}
|
||||
}
|
||||
if(Boolean(this._secondaryNpcMC) && Boolean(this._secondaryNpcMC.parent != null) && this._secondaryNpcMC.parent is MovieClip)
|
||||
{
|
||||
this._secondaryNpcMC.parent.removeChild(this._secondaryNpcMC);
|
||||
}
|
||||
if(Boolean(this._namebar))
|
||||
{
|
||||
this._namebar.destroy();
|
||||
this._namebar = null;
|
||||
}
|
||||
if(Boolean(this._healthBar))
|
||||
{
|
||||
this._healthBar = null;
|
||||
}
|
||||
if(Boolean(this._npcAvatarView))
|
||||
{
|
||||
if(this._npcAvatarView.parent != null)
|
||||
{
|
||||
this._npcAvatarView.parent.removeChild(this._npcAvatarView);
|
||||
}
|
||||
this._npcAvatarView.destroy(true);
|
||||
}
|
||||
this._hitTextTween = null;
|
||||
}
|
||||
|
||||
public function updateHealthBar(healthPercent:int, damageAmount:int, criticalHit:Boolean, displayText:Boolean) : void
|
||||
{
|
||||
var text:String = null;
|
||||
if(Boolean(this._healthBar))
|
||||
{
|
||||
if(healthPercent == 0)
|
||||
{
|
||||
this._healthBar.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._healthBar.hpBar.width = this._healthBar.hpEnemyBarContainer.width * (healthPercent / 100);
|
||||
}
|
||||
}
|
||||
if(displayText)
|
||||
{
|
||||
if(damageAmount > 0 && Boolean(this._npcMC))
|
||||
{
|
||||
if(criticalHit)
|
||||
{
|
||||
text = "Fierce!\n" + Math.abs(damageAmount) * -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
text = String(Math.abs(damageAmount) * -1);
|
||||
}
|
||||
this.playHitText(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function playHitText(hitString:String) : void
|
||||
{
|
||||
var attachmentPoint:Point = null;
|
||||
this._hitText.visible = true;
|
||||
this._hitText.alpha = 2;
|
||||
this._hitText.text = hitString;
|
||||
try
|
||||
{
|
||||
attachmentPoint = this._npcMC.getAttachmentPoint();
|
||||
this._hitText.x = attachmentPoint.x + this.x - this._hitText.textWidth * 0.5;
|
||||
this._hitText.y = attachmentPoint.y + this.y;
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
_hitText.x = this.x - _hitText.textWidth * 0.5;
|
||||
_hitText.y = this.y - _hitText.textHeight;
|
||||
}
|
||||
if(parent != null)
|
||||
{
|
||||
this._hitText.x += parent.x;
|
||||
this._hitText.y += parent.y;
|
||||
}
|
||||
if(Boolean(this._hitTextTween))
|
||||
{
|
||||
this._hitTextTween.resetValues({
|
||||
"y":this._hitText.y - 90,
|
||||
"alpha":0
|
||||
});
|
||||
this._hitTextTween.beginning();
|
||||
this._hitTextTween.paused = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._hitTextTween = new GTween(this._hitText,1,{
|
||||
"y":this._hitText.y - 90,
|
||||
"alpha":0
|
||||
},{"ease":Linear.easeNone});
|
||||
}
|
||||
}
|
||||
|
||||
public function playAnimationState(anim:int, bFlip:Boolean, loopMode:int, callback:Function) : void
|
||||
{
|
||||
if(Boolean(this._npcAvatarView))
|
||||
{
|
||||
this._npcAvatarView.playAnim(anim,bFlip,loopMode,callback);
|
||||
}
|
||||
}
|
||||
|
||||
public function get npcMC() : MovieClip
|
||||
{
|
||||
return this._npcMC;
|
||||
}
|
||||
|
||||
public function get defId() : int
|
||||
{
|
||||
return this._npcDef.defId;
|
||||
}
|
||||
|
||||
public function get npcDef() : Object
|
||||
{
|
||||
return this._npcDef;
|
||||
}
|
||||
|
||||
public function get secondaryNpcMC() : MovieClip
|
||||
{
|
||||
return this._secondaryNpcMC;
|
||||
}
|
||||
|
||||
private function onMediaLoaded(img:MovieClip) : void
|
||||
{
|
||||
this._npcMC = img;
|
||||
addChild(this._npcMC);
|
||||
if(this._npcMC.hasOwnProperty("eye"))
|
||||
{
|
||||
this._eye = this._npcMC.eye;
|
||||
}
|
||||
if(this._npcDef.headMediaRefId != 0)
|
||||
{
|
||||
this._mediaHelperObj = new MediaHelper();
|
||||
this._mediaHelperObj.init(this._npcDef.headMediaRefId,this.secondaryNPCLoaded);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.loadingComplete();
|
||||
}
|
||||
}
|
||||
|
||||
private function secondaryNPCLoaded(img:MovieClip) : void
|
||||
{
|
||||
if(img.getChildAt(0) is MovieClip)
|
||||
{
|
||||
this._secondaryNpcMC = MovieClip(img.getChildAt(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
this._secondaryNpcMC = img;
|
||||
}
|
||||
this._mediaHelperObj.destroy();
|
||||
this._mediaHelperObj = null;
|
||||
this.loadingComplete();
|
||||
}
|
||||
|
||||
private function redrawCallback(layerAnim:LayerAnim) : void
|
||||
{
|
||||
if(Boolean(layerAnim) && Boolean(this._npcAvatarView))
|
||||
{
|
||||
if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_LAND)
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_IDLE_SE,false,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
else if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_OCEAN)
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_FLOAT,false,LayerAnim.AN_FLOAT,null);
|
||||
}
|
||||
addChild(this._npcAvatarView);
|
||||
this.loadingComplete();
|
||||
}
|
||||
}
|
||||
|
||||
private function loadingComplete() : void
|
||||
{
|
||||
this._npcState = NPC_STATE_LOADED;
|
||||
if(this._npcMC != null && this._npcMC.hasOwnProperty("setInit"))
|
||||
{
|
||||
this._npcMC.setInit(QuestManager._questDifficultyLevel);
|
||||
if(this._npcMC.hasOwnProperty("watcher"))
|
||||
{
|
||||
this._beam = this._npcMC.watcher;
|
||||
}
|
||||
}
|
||||
QuestManager._layerManager.room_chat.addChild(this._hitText);
|
||||
if(this._onLoadingCompleteCallback != null)
|
||||
{
|
||||
this._onLoadingCompleteCallback();
|
||||
}
|
||||
}
|
||||
|
||||
public function setSwfState(swfStateName:String) : Number
|
||||
{
|
||||
if(this._npcMC != null)
|
||||
{
|
||||
return this._npcMC.setStateByScript(swfStateName);
|
||||
}
|
||||
if(this._npcAvatarView != null)
|
||||
{
|
||||
if(swfStateName == "dance")
|
||||
{
|
||||
if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_LAND)
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_DANCE,this._npcFacingSW,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
else if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_OCEAN)
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_WATER_JIG,this._npcFacingSW,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
}
|
||||
else if(swfStateName == "hop")
|
||||
{
|
||||
if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_LAND)
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_HOP,this._npcFacingSW,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
else if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_OCEAN)
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_WATER_DIVE,this._npcFacingSW,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
}
|
||||
else if(swfStateName == "spin")
|
||||
{
|
||||
if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_OCEAN)
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_WATER_SPIN,this._npcFacingSW,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
}
|
||||
else if(swfStateName == "idle" || swfStateName == "facese")
|
||||
{
|
||||
this._npcFacingSW = false;
|
||||
if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_LAND)
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_IDLE_SE,false,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
else if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_OCEAN)
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_FLOAT,false,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
}
|
||||
else if(swfStateName == "facesw")
|
||||
{
|
||||
this._npcFacingSW = true;
|
||||
if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_LAND)
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_IDLE_SE,true,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
else if(RoomManagerWorld.instance.roomEnviroType == Utility.ENVIRO_OCEAN)
|
||||
{
|
||||
this.playAnimationState(LayerAnim.AN_FLOAT,true,LayerAnim.PLAY_LOOP,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,743 @@
|
||||
package avatar
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.Event;
|
||||
import flash.events.MouseEvent;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class NameBar extends MovieClip
|
||||
{
|
||||
|
||||
private static var _getNamebarIconsFunc:Function;
|
||||
|
||||
public static var NON_BUDDY:String = "nonBuddy";
|
||||
|
||||
public static var BUDDY:String = "buddy";
|
||||
|
||||
public static var GUIDE:String = "guide";
|
||||
|
||||
public static const LEVEL_SHAPES:Array = new Array(1851,1858,1853,1857);
|
||||
|
||||
public static const MAX_COLORS:int = 10;
|
||||
|
||||
private static var BADGE_ID_VIP_CAMERA:int = 31;
|
||||
|
||||
private var _iconIdsArray:Array;
|
||||
|
||||
private var _isBlocked:Boolean;
|
||||
|
||||
private var _nubType:String;
|
||||
|
||||
private var _left:MovieClip;
|
||||
|
||||
private var _mid:MovieClip;
|
||||
|
||||
private var _right:MovieClip;
|
||||
|
||||
private var _avName:MovieClip;
|
||||
|
||||
private var _meter:MovieClip;
|
||||
|
||||
private var _shape:MovieClip;
|
||||
|
||||
private var _iconsMediaHelperArray:Array;
|
||||
|
||||
private var _iconImages:Array;
|
||||
|
||||
private var _nubDataArray:Array;
|
||||
|
||||
private var _nameBarDataToBeLoaded:int;
|
||||
|
||||
private var _currframeName:String;
|
||||
|
||||
private var _packedNameBarData:int;
|
||||
|
||||
private var _badgeId:int;
|
||||
|
||||
private var _levelShapeHelper:MediaHelper;
|
||||
|
||||
private var _shapesMediaHelperArray:Array;
|
||||
|
||||
private var _currShapeMouse:MovieClip;
|
||||
|
||||
private var _currShapeUp:MovieClip;
|
||||
|
||||
private var _isMember:Boolean;
|
||||
|
||||
public function NameBar(initNubType:String = "nonBuddy", initIsBlocked:Boolean = false)
|
||||
{
|
||||
super();
|
||||
if(Boolean(this["e"].currentFrameLabel))
|
||||
{
|
||||
this._left = this["e"][String(this["e"].currentFrameLabel)];
|
||||
}
|
||||
else
|
||||
{
|
||||
this._left = this["e"];
|
||||
}
|
||||
if(Boolean(this["n"].currentFrameLabel))
|
||||
{
|
||||
this._mid = this["n"][String(this["n"].currentFrameLabel)];
|
||||
}
|
||||
else
|
||||
{
|
||||
this._mid = this["n"];
|
||||
}
|
||||
if(this["meter"] != null)
|
||||
{
|
||||
if(Boolean(this["meter"].currentFrameLabel))
|
||||
{
|
||||
this._meter = this["meter"][String(this["meter"].currentFrameLabel)];
|
||||
}
|
||||
else
|
||||
{
|
||||
this._meter = this["meter"];
|
||||
}
|
||||
}
|
||||
if(this["shape"] != null)
|
||||
{
|
||||
if(Boolean(this["shape"].currentFrameLabel))
|
||||
{
|
||||
this._shape = this["shape"][String(this["shape"].currentFrameLabel)];
|
||||
}
|
||||
else
|
||||
{
|
||||
this._shape = this["shape"];
|
||||
}
|
||||
}
|
||||
this._right = this["selnub"];
|
||||
this._avName = this["c"];
|
||||
if(!(Boolean(this._left) && Boolean(this._mid) && Boolean(this._right) && Boolean(this._avName) && this._avName.txt))
|
||||
{
|
||||
throw new Error("NameBar is missing parts or parts are named improperly!");
|
||||
}
|
||||
this._currframeName = "black";
|
||||
this.isBlocked = initIsBlocked;
|
||||
this.nubType = initNubType;
|
||||
this._iconsMediaHelperArray = [];
|
||||
this._shapesMediaHelperArray = [];
|
||||
this._iconImages = [];
|
||||
this._nubDataArray = [];
|
||||
if(_getNamebarIconsFunc != null)
|
||||
{
|
||||
this._iconIdsArray = _getNamebarIconsFunc();
|
||||
}
|
||||
if(!this._iconIdsArray)
|
||||
{
|
||||
this._iconIdsArray = [];
|
||||
}
|
||||
this._nameBarDataToBeLoaded = -1;
|
||||
this.cacheAsBitmap = true;
|
||||
addEventListener(MouseEvent.ROLL_OVER,this.onOverHandler,false,0,true);
|
||||
addEventListener(MouseEvent.ROLL_OUT,this.onOutHandler,false,0,true);
|
||||
}
|
||||
|
||||
public static function set getNamebarIconsFunc(func:Function) : void
|
||||
{
|
||||
_getNamebarIconsFunc = func;
|
||||
}
|
||||
|
||||
public static function isVIPBadge(packedNamebarData:int) : Boolean
|
||||
{
|
||||
var badgeIcon:int = packedNamebarData >> 8 & 0xFF;
|
||||
return badgeIcon + 1 == BADGE_ID_VIP_CAMERA;
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
this.removeListeners();
|
||||
}
|
||||
|
||||
public function set isBlocked(value:Boolean) : void
|
||||
{
|
||||
this._isBlocked = value;
|
||||
if(this._nubType != GUIDE)
|
||||
{
|
||||
this._right.blocked.visible = this._isBlocked;
|
||||
}
|
||||
}
|
||||
|
||||
public function setColorAndBadge(packedData:int) : void
|
||||
{
|
||||
this._packedNameBarData = packedData;
|
||||
var color:int = packedData & 0xFF;
|
||||
var badgeIcon:int = packedData >> 8 & 0xFF;
|
||||
this._badgeId = badgeIcon + 1;
|
||||
if(Boolean(this["e"].currentFrameLabel))
|
||||
{
|
||||
this.setColor(color);
|
||||
this.setBadgeIcon(badgeIcon);
|
||||
}
|
||||
}
|
||||
|
||||
public function setColorBadgeAndXp(packedData:int, level:int, isMember:Boolean, isInQuestRoom:Boolean = false) : void
|
||||
{
|
||||
this.setColorAndBadge(packedData);
|
||||
var showQuestLevel:Boolean = (packedData >> 16 & 0xFF) == 0 && isMember;
|
||||
this._isMember = isMember;
|
||||
if(level > 0 && (isInQuestRoom || showQuestLevel))
|
||||
{
|
||||
if(Boolean(this._currShapeMouse) && Boolean(this._currShapeMouse.level != null) && this._currShapeMouse.level == level)
|
||||
{
|
||||
this.setCurrShape();
|
||||
}
|
||||
else if(level > 0)
|
||||
{
|
||||
this.setShape(level);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(this._shape.mouse.up.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.up.icon.removeChildAt(0);
|
||||
}
|
||||
while(this._shape.mouse.mouse.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.mouse.icon.removeChildAt(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setNubType(value:String, changeDimensions:Boolean = true) : void
|
||||
{
|
||||
this.nubType = value;
|
||||
this.resize(changeDimensions);
|
||||
}
|
||||
|
||||
public function setAvName(value:String, changeDimensions:Boolean = true) : void
|
||||
{
|
||||
this._avName.txt.text = value;
|
||||
this.resize(changeDimensions);
|
||||
}
|
||||
|
||||
public function removeShape() : void
|
||||
{
|
||||
while(this._shape.mouse.up.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.up.icon.removeChildAt(0);
|
||||
}
|
||||
while(this._shape.mouse.mouse.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.mouse.icon.removeChildAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateMeter(value:int) : void
|
||||
{
|
||||
this.setMeter(value);
|
||||
}
|
||||
|
||||
public function getMeterValue() : int
|
||||
{
|
||||
if(Boolean(this["meter"]))
|
||||
{
|
||||
return this["meter"].hpBar.width;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function removeListeners() : void
|
||||
{
|
||||
removeEventListener(MouseEvent.ROLL_OVER,this.onOverHandler);
|
||||
removeEventListener(MouseEvent.ROLL_OUT,this.onOutHandler);
|
||||
}
|
||||
|
||||
public function get nubData() : Array
|
||||
{
|
||||
return this._nubDataArray;
|
||||
}
|
||||
|
||||
public function set nubData(data:Array) : void
|
||||
{
|
||||
this._nubDataArray = data;
|
||||
}
|
||||
|
||||
public function get iconIds() : Array
|
||||
{
|
||||
return this._iconIdsArray;
|
||||
}
|
||||
|
||||
public function set iconIds(ids:Array) : void
|
||||
{
|
||||
this._iconIdsArray = ids;
|
||||
}
|
||||
|
||||
public function get packedNameBarData() : int
|
||||
{
|
||||
return this._packedNameBarData;
|
||||
}
|
||||
|
||||
public function get xpShapeIcons() : Object
|
||||
{
|
||||
return {
|
||||
"mouseIcon":this._currShapeMouse,
|
||||
"upIcon":this._currShapeUp
|
||||
};
|
||||
}
|
||||
|
||||
public function set xpShapeIcons(obj:Object) : void
|
||||
{
|
||||
this._currShapeMouse = obj.mouseIcon;
|
||||
this._currShapeUp = obj.upIcon;
|
||||
if(Boolean(this._currShapeMouse) && this._currShapeMouse.level != null)
|
||||
{
|
||||
this.setShape(this._currShapeMouse.level);
|
||||
}
|
||||
}
|
||||
|
||||
public function get currentLevel() : int
|
||||
{
|
||||
if(Boolean(this._currShapeMouse) && this._currShapeMouse.level != null)
|
||||
{
|
||||
return this._currShapeMouse.level;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function setColor(colorValue:int) : void
|
||||
{
|
||||
var frameId:int = 0;
|
||||
if(colorValue == 0)
|
||||
{
|
||||
frameId = 4;
|
||||
}
|
||||
else if(colorValue > 3 && colorValue <= MAX_COLORS)
|
||||
{
|
||||
frameId = colorValue + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
frameId = Math.min(4,colorValue);
|
||||
}
|
||||
this._currframeName = this["e"].currentLabels[frameId - 1].name;
|
||||
this["e"].gotoAndStop(this._currframeName);
|
||||
this._left = this["e"][this._currframeName];
|
||||
this["n"].gotoAndStop(this._currframeName);
|
||||
this._mid = this["n"][this._currframeName];
|
||||
if(Boolean(this._meter))
|
||||
{
|
||||
this["meter"].gotoAndStop(this._currframeName);
|
||||
this._meter = this["meter"][this._currframeName];
|
||||
}
|
||||
if(Boolean(this._shape))
|
||||
{
|
||||
this["shape"].gotoAndStop(this._currframeName);
|
||||
this._shape = this["shape"][this._currframeName];
|
||||
}
|
||||
if(Boolean(this["selnub"].nub.currentFrameLabel))
|
||||
{
|
||||
this["selnub"].nub.gotoAndStop(this._currframeName);
|
||||
this._right = this["selnub"];
|
||||
}
|
||||
if(Boolean(this._avName.currentFrameLabel))
|
||||
{
|
||||
this._avName.gotoAndStop(this._currframeName);
|
||||
}
|
||||
this._left.mouse.gotoAndStop(1);
|
||||
this._mid.mouse.gotoAndStop(1);
|
||||
if(Boolean(this._shape))
|
||||
{
|
||||
this._shape.mouse.gotoAndStop(1);
|
||||
}
|
||||
if(Boolean(this._right.nub.currentFrameLabel))
|
||||
{
|
||||
this._right.nub[this._currframeName].mouse.gotoAndStop(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._right.nub.mouse.gotoAndStop(1);
|
||||
}
|
||||
}
|
||||
|
||||
private function setBadgeIcon(badgeIcon:int) : void
|
||||
{
|
||||
var id:int = 0;
|
||||
if(this._iconIdsArray.length > 0)
|
||||
{
|
||||
if(this["selnub"].currentFrameLabel == "buddy")
|
||||
{
|
||||
while(this._right.nub[String(this._right.nub.currentFrameLabel)].mouse.mouse.icon.numChildren > 0)
|
||||
{
|
||||
this._right.nub[String(this._right.nub.currentFrameLabel)].mouse.mouse.icon.removeChildAt(0);
|
||||
}
|
||||
while(this._right.nub[String(this._right.nub.currentFrameLabel)].mouse.up.icon.numChildren > 0)
|
||||
{
|
||||
this._right.nub[String(this._right.nub.currentFrameLabel)].mouse.up.icon.removeChildAt(0);
|
||||
}
|
||||
id = int(this._iconIdsArray[badgeIcon]);
|
||||
badgeIcon *= 2;
|
||||
if(badgeIcon % 2 != 0)
|
||||
{
|
||||
badgeIcon++;
|
||||
}
|
||||
if(Boolean(this._iconImages[badgeIcon]) && Boolean(this._iconImages[badgeIcon + 1]))
|
||||
{
|
||||
this._right.nub[String(this._right.nub.currentFrameLabel)].mouse.mouse.icon.addChild(this._iconImages[badgeIcon]);
|
||||
this._right.nub[String(this._right.nub.currentFrameLabel)].mouse.up.icon.addChild(this._iconImages[badgeIcon + 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._nubDataArray[badgeIcon] = this._right.nub[String(this._right.nub.currentFrameLabel)].mouse;
|
||||
this.loadIcon(id,badgeIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._nameBarDataToBeLoaded = this._packedNameBarData;
|
||||
}
|
||||
}
|
||||
|
||||
private function set nubType(value:String) : void
|
||||
{
|
||||
if(value == "")
|
||||
{
|
||||
this._right.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._right.visible = true;
|
||||
this._nubType = value;
|
||||
this._right.gotoAndStop(this._nubType);
|
||||
if(Boolean(this._right.nub.currentFrameLabel))
|
||||
{
|
||||
this._right.nub.gotoAndStop(this._currframeName);
|
||||
this._right.nub[this._currframeName].mouse.gotoAndStop(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._right.nub.mouse.gotoAndStop(1);
|
||||
}
|
||||
if(this._isBlocked && this._nubType != GUIDE)
|
||||
{
|
||||
this._right.blocked.gotoAndStop(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function resize(changeDimensions:Boolean) : void
|
||||
{
|
||||
var offset:int = 0;
|
||||
var mid:MovieClip = null;
|
||||
var left:MovieClip = null;
|
||||
var shape:MovieClip = null;
|
||||
var meter:MovieClip = null;
|
||||
if(changeDimensions)
|
||||
{
|
||||
mid = this._mid.parent != this ? MovieClip(this._mid.parent) : this._mid;
|
||||
left = this._left.parent != this ? MovieClip(this._left.parent) : this._left;
|
||||
shape = Boolean(this._shape) && this._shape.parent != this ? MovieClip(this._shape.parent) : this._shape;
|
||||
meter = Boolean(this._meter) && this._meter.parent != this ? MovieClip(this._meter.parent) : this._meter;
|
||||
if(this._nubType == NON_BUDDY && !this._isBlocked)
|
||||
{
|
||||
offset = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = 20;
|
||||
}
|
||||
this._avName.txt.width = 300;
|
||||
if(this._avName.txt.textWidth + offset < 60)
|
||||
{
|
||||
mid.width = 60 + 0.5 * this._right.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
mid.width = Math.ceil(this._avName.txt.textWidth + offset);
|
||||
}
|
||||
mid.x = mid.width * 0.5 * -1;
|
||||
this._avName.txt.width = mid.width - offset + 5;
|
||||
left.x = mid.x - left.width;
|
||||
this._avName.x = mid.x + (this._isMember ? 2 : -2);
|
||||
this._right.x = mid.x + mid.width - 1;
|
||||
if(Boolean(shape))
|
||||
{
|
||||
shape.x = left.x;
|
||||
}
|
||||
if(Boolean(meter))
|
||||
{
|
||||
meter.width = this._avName.txt.width + 18;
|
||||
meter.x = this._avName.x - 7;
|
||||
}
|
||||
}
|
||||
this._left.mouse.gotoAndStop(1);
|
||||
this._mid.mouse.gotoAndStop(1);
|
||||
if(Boolean(this._shape))
|
||||
{
|
||||
this._shape.mouse.gotoAndStop(1);
|
||||
}
|
||||
if(Boolean(this._right.nub.currentFrameLabel))
|
||||
{
|
||||
this._right.nub[this._currframeName].mouse.gotoAndStop(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._right.nub.mouse.gotoAndStop(1);
|
||||
}
|
||||
}
|
||||
|
||||
private function loadIcon(id:int, index:int) : void
|
||||
{
|
||||
var iconsMediaHelper:MediaHelper = new MediaHelper();
|
||||
iconsMediaHelper.init(id,this.onIconsLoaded,index);
|
||||
this._iconsMediaHelperArray[index] = iconsMediaHelper;
|
||||
iconsMediaHelper = new MediaHelper();
|
||||
iconsMediaHelper.init(id,this.onIconsLoaded,index + 1);
|
||||
this._iconsMediaHelperArray[index + 1] = iconsMediaHelper;
|
||||
}
|
||||
|
||||
private function onIconsLoaded(img:MovieClip) : void
|
||||
{
|
||||
var nub:Object = null;
|
||||
var index:int = 0;
|
||||
if(Boolean(img))
|
||||
{
|
||||
img.cacheAsBitmap = true;
|
||||
index = int(img.passback);
|
||||
this._iconImages[index] = img;
|
||||
if(img.passback % 2 == 0)
|
||||
{
|
||||
nub = this._nubDataArray[index].mouse.icon;
|
||||
while(nub.numChildren > 0)
|
||||
{
|
||||
nub.removeChildAt(0);
|
||||
}
|
||||
nub.addChild(img);
|
||||
}
|
||||
else
|
||||
{
|
||||
nub = this._nubDataArray[index - 1].up.icon;
|
||||
while(nub.numChildren > 0)
|
||||
{
|
||||
nub.removeChildAt(0);
|
||||
}
|
||||
nub.addChild(img);
|
||||
}
|
||||
if(Boolean(this._iconsMediaHelperArray[index]))
|
||||
{
|
||||
this._iconsMediaHelperArray[index].destroy();
|
||||
this._iconsMediaHelperArray[index] = null;
|
||||
delete this._iconsMediaHelperArray[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function setCurrShape() : void
|
||||
{
|
||||
while(this._shape.mouse.up.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.up.icon.removeChildAt(0);
|
||||
}
|
||||
this._shape.mouse.up.icon.addChild(this._currShapeUp);
|
||||
while(this._shape.mouse.mouse.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.mouse.icon.removeChildAt(0);
|
||||
}
|
||||
this._shape.mouse.mouse.icon.addChild(this._currShapeMouse);
|
||||
}
|
||||
|
||||
private function setShape(level:int) : void
|
||||
{
|
||||
var shapeId:int = 0;
|
||||
if(level > 0)
|
||||
{
|
||||
if(this._currShapeMouse == null || this._currShapeMouse.level != level && Math.floor(this._currShapeMouse.level / 5) != Math.floor(level / 5))
|
||||
{
|
||||
shapeId = Math.floor(level / 5) > LEVEL_SHAPES.length - 1 ? int(LEVEL_SHAPES[LEVEL_SHAPES.length - 1]) : int(LEVEL_SHAPES[Math.floor(level / 5)]);
|
||||
this._levelShapeHelper = new MediaHelper();
|
||||
this._levelShapeHelper.init(shapeId,this.onLevelShapeLoaded,-1);
|
||||
this._shapesMediaHelperArray.push(this._levelShapeHelper);
|
||||
this._levelShapeHelper = new MediaHelper();
|
||||
this._levelShapeHelper.init(shapeId,this.onLevelShapeLoaded,level);
|
||||
this._shapesMediaHelperArray.push(this._levelShapeHelper);
|
||||
}
|
||||
else
|
||||
{
|
||||
while(this._shape.mouse.up.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.up.icon.removeChildAt(0);
|
||||
}
|
||||
this._shape.mouse.up.icon.addChild(this._currShapeUp);
|
||||
while(this._shape.mouse.mouse.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.mouse.icon.removeChildAt(0);
|
||||
}
|
||||
this._shape.mouse.mouse.icon.addChild(this._currShapeMouse);
|
||||
this._currShapeMouse.text.text = level;
|
||||
this._currShapeUp.text.text = level;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(this._shape.mouse.up.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.up.icon.removeChildAt(0);
|
||||
}
|
||||
while(this._shape.mouse.mouse.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.mouse.icon.removeChildAt(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onLevelShapeLoaded(img:MovieClip) : void
|
||||
{
|
||||
var shape:MovieClip = null;
|
||||
if(Boolean(img))
|
||||
{
|
||||
shape = MovieClip(img.getChildAt(0));
|
||||
if(img.passback == -1)
|
||||
{
|
||||
this._currShapeUp = shape;
|
||||
if(this._isMember)
|
||||
{
|
||||
this._currShapeUp.gotoAndStop("member");
|
||||
}
|
||||
if(Boolean(this._currShapeMouse))
|
||||
{
|
||||
this._currShapeUp.text.text = this._currShapeMouse.level;
|
||||
}
|
||||
this._shapesMediaHelperArray[0].destroy();
|
||||
this._shapesMediaHelperArray.splice(0,1);
|
||||
while(this._shape.mouse.up.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.up.icon.removeChildAt(0);
|
||||
}
|
||||
this._shape.mouse.up.icon.addChild(this._currShapeUp);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._currShapeMouse = shape;
|
||||
if(this._isMember)
|
||||
{
|
||||
this._currShapeMouse.gotoAndStop("member");
|
||||
}
|
||||
this._currShapeMouse.level = this._currShapeMouse.text.text = img.passback;
|
||||
if(Boolean(this._currShapeUp))
|
||||
{
|
||||
this._currShapeUp.text.text = this._currShapeMouse.level;
|
||||
}
|
||||
this._shapesMediaHelperArray[this._shapesMediaHelperArray.length - 1].destroy();
|
||||
this._shapesMediaHelperArray.pop();
|
||||
while(this._shape.mouse.mouse.icon.numChildren > 0)
|
||||
{
|
||||
this._shape.mouse.mouse.icon.removeChildAt(0);
|
||||
}
|
||||
this._shape.mouse.mouse.icon.addChild(this._currShapeMouse);
|
||||
}
|
||||
this._shape.mouse.gotoAndStop(1);
|
||||
}
|
||||
}
|
||||
|
||||
private function setMeter(healthPercentage:int) : void
|
||||
{
|
||||
if(Boolean(this["meter"]))
|
||||
{
|
||||
this["meter"].hpBar.width = this["meter"].hpBarContainer.width * (healthPercentage / 100);
|
||||
}
|
||||
}
|
||||
|
||||
private function onOverHandler(evt:MouseEvent) : void
|
||||
{
|
||||
this._left.mouse.gotoAndPlay(1);
|
||||
this._mid.mouse.gotoAndPlay(1);
|
||||
if(Boolean(this._shape))
|
||||
{
|
||||
this._shape.mouse.gotoAndPlay(1);
|
||||
}
|
||||
if(Boolean(this._right.nub.currentFrameLabel))
|
||||
{
|
||||
this._right.nub[String(this._right.nub.currentFrameLabel)].mouse.gotoAndPlay(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._right.nub.mouse.gotoAndPlay(1);
|
||||
}
|
||||
if(this._isBlocked && this._nubType != GUIDE)
|
||||
{
|
||||
this._right.blocked.mouse.gotoAndPlay(1);
|
||||
}
|
||||
}
|
||||
|
||||
private function onOutHandler(evt:MouseEvent) : void
|
||||
{
|
||||
var rightNub:MovieClip = null;
|
||||
if(Boolean(this._right.nub[String(this._right.nub.currentFrameLabel)]))
|
||||
{
|
||||
rightNub = this._right.nub[String(this._right.nub.currentFrameLabel)];
|
||||
}
|
||||
else
|
||||
{
|
||||
rightNub = this._right.nub;
|
||||
}
|
||||
if(this._left.mouse.currentFrame > 1)
|
||||
{
|
||||
this.playBackwards(this._left.mouse);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._left.mouse.stop();
|
||||
}
|
||||
if(this._mid.mouse.currentFrame > 1)
|
||||
{
|
||||
this.playBackwards(this._mid.mouse);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._mid.mouse.stop();
|
||||
}
|
||||
if(Boolean(this._shape))
|
||||
{
|
||||
if(this._shape.mouse.currentFrame > 1)
|
||||
{
|
||||
this.playBackwards(this._shape.mouse);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._shape.mouse.stop();
|
||||
}
|
||||
}
|
||||
if(rightNub.mouse.currentFrame > 1)
|
||||
{
|
||||
this.playBackwards(rightNub.mouse);
|
||||
}
|
||||
else
|
||||
{
|
||||
rightNub.mouse.stop();
|
||||
}
|
||||
if(this._isBlocked && this._nubType != GUIDE)
|
||||
{
|
||||
if(this._right.blocked.mouse.currentFrame > 1)
|
||||
{
|
||||
this.playBackwards(this._right.blocked.mouse);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._right.blocked.mouse.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function playBackwards(mc:MovieClip) : void
|
||||
{
|
||||
mc.addEventListener(Event.ENTER_FRAME,this.pbFrameHandler,false,0,true);
|
||||
}
|
||||
|
||||
private function pbFrameHandler(evt:Event) : void
|
||||
{
|
||||
var mch:MovieClip = null;
|
||||
if(Boolean(evt.target as MovieClip))
|
||||
{
|
||||
mch = MovieClip(evt.target);
|
||||
if(mch.currentFrame == 1)
|
||||
{
|
||||
mch.removeEventListener(Event.ENTER_FRAME,this.pbFrameHandler);
|
||||
return;
|
||||
}
|
||||
mch.prevFrame();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.analytics.SBTracker;
|
||||
import flash.display.MovieClip;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
|
||||
public class NewWorldAvatar implements INewAvatar
|
||||
{
|
||||
|
||||
public function NewWorldAvatar()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function screenInitCallback(soundBtn:MovieClip) : void
|
||||
{
|
||||
soundBtn.visible = false;
|
||||
}
|
||||
|
||||
public function get playSound() : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function newAvatarData(type:int, avatarName:String, avatarNameIndexes:Array, avNameValidGuiCallback:Function, isShopBuy:Boolean = false) : void
|
||||
{
|
||||
SBTracker.trackPageview("/game/play/popup/avatarSwitch/buyAnimal");
|
||||
var avNameValid:Boolean = Boolean(avatarName && avatarName != "" && RegExp(/a-zA-Z0-9 /)["exec"](avatarName) == null);
|
||||
if(avNameValid)
|
||||
{
|
||||
AvatarSwitch.addNewWorldAvatar(type,avatarName,avatarNameIndexes,isShopBuy);
|
||||
}
|
||||
if(avNameValidGuiCallback != null && !AvatarSwitch.isAddingSlot)
|
||||
{
|
||||
avNameValidGuiCallback(avNameValid);
|
||||
}
|
||||
if(avNameValid)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
}
|
||||
}
|
||||
|
||||
public function hideConnectingMsg() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function nameTypeScreenDone() : void
|
||||
{
|
||||
GuiManager.closeAvatarCreator();
|
||||
}
|
||||
|
||||
public function logInForCreateAvatarData() : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,766 @@
|
||||
package avatar
|
||||
{
|
||||
import com.adobe.utils.StringUtil;
|
||||
import com.sbi.client.SFEvent;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.loader.FileServerEvent;
|
||||
import com.sbi.popup.*;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.external.ExternalInterface;
|
||||
import flash.text.TextFormat;
|
||||
import game.MinigameInfo;
|
||||
import game.MinigameManager;
|
||||
import gui.ActionManager;
|
||||
import gui.ChatHistory;
|
||||
import gui.EmoticonManager;
|
||||
import gui.EmoticonUtility;
|
||||
import gui.GuiManager;
|
||||
import gui.SafeChatManager;
|
||||
import loader.DefPacksDefHelper;
|
||||
import loader.JCDefHelper;
|
||||
import localization.LocalizationManager;
|
||||
import quest.QuestXtCommManager;
|
||||
import room.RoomManagerWorld;
|
||||
|
||||
public class UserCommXtCommManager
|
||||
{
|
||||
|
||||
public static var RAW_STR:String;
|
||||
|
||||
private static var _mainHud:MovieClip;
|
||||
|
||||
private static var _chatHist:ChatHistory;
|
||||
|
||||
private static var _emoteMgr:EmoticonManager;
|
||||
|
||||
private static var _actionMgr:ActionManager;
|
||||
|
||||
private static var _roomMgr:RoomManagerWorld;
|
||||
|
||||
private static var _spellingCorrections:Object;
|
||||
|
||||
private static var _emoteDefs:Object;
|
||||
|
||||
private static var _specialWords:Object;
|
||||
|
||||
private static var _replacedWords:Object;
|
||||
|
||||
public static const CHAT_TYPE_TYPED:int = 0;
|
||||
|
||||
public static const CHAT_TYPE_SAFE:int = 1;
|
||||
|
||||
public static const CHAT_TYPE_EMOTE:int = 2;
|
||||
|
||||
public static const CHAT_TYPE_ACTION:int = 3;
|
||||
|
||||
public static const CHAT_TYPE_ATTACHMENT:int = 4;
|
||||
|
||||
public static const CHAT_TYPE_PERM_EMOTE:int = 5;
|
||||
|
||||
public static const CHAT_TYPE_SLIDE:int = 6;
|
||||
|
||||
public static const CHAT_TYPE_PET_ACTION:int = 7;
|
||||
|
||||
public static const CHAT_TYPE_BLEND_COLOR:int = 8;
|
||||
|
||||
public static const CHAT_TYPE_LIMITED:int = 9;
|
||||
|
||||
public static const CHAT_TYPE_ALPHA_LEVEL:int = 10;
|
||||
|
||||
public static const CHAT_TYPE_CUST_ADVENTURE:int = 11;
|
||||
|
||||
public static const CHAT_TYPE_CUST_PVP:int = 12;
|
||||
|
||||
private static var _playerSfsUserId:int = -1;
|
||||
|
||||
public function UserCommXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
DebugUtility.debugTrace("UserCommXtCommManager init - initializing");
|
||||
_mainHud = GuiManager.mainHud;
|
||||
_chatHist = GuiManager.chatHist;
|
||||
_emoteMgr = GuiManager.emoteMgr;
|
||||
_actionMgr = GuiManager.actionMgr;
|
||||
_roomMgr = RoomManagerWorld.instance;
|
||||
_playerSfsUserId = AvatarManager.playerSfsUserId;
|
||||
RAW_STR = gMainFrame.server.rawProtocolSeparator;
|
||||
var dpdh:DefPacksDefHelper = new DefPacksDefHelper();
|
||||
dpdh.init(DefPacksDefHelper.DEF_EMOTICON,onEmoticonDefsLoaded,null,FileServerEvent.AMF3_TYPE);
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_EMOTICON] = dpdh;
|
||||
dpdh = new DefPacksDefHelper();
|
||||
dpdh.init(uint(DefPacksDefHelper.AUTO_CORRECT_TEXT_FILE_TO_APPEND_TO + "" + 0),onAutoCorrectListLoaded,null,FileServerEvent.PLAIN_TEXT_TYPE);
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.AUTO_CORRECT_TEXT_FILE_TO_APPEND_TO + "" + 0] = dpdh;
|
||||
_specialWords = {};
|
||||
_specialWords[LocalizationManager.translateIdOnly(14855)] = LocalizationManager.translateIdOnly(11142);
|
||||
}
|
||||
|
||||
private static function onAutoCorrectListLoaded(df:DefPacksDefHelper) : void
|
||||
{
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.AUTO_CORRECT_TEXT_FILE_TO_APPEND_TO + "" + 0] = null;
|
||||
var str:String = df.def.toString().toLowerCase() as String;
|
||||
_spellingCorrections = {};
|
||||
var autoCorrectList:Array = str.split("\r\n");
|
||||
for(var i:int = 0; i < autoCorrectList.length; i++)
|
||||
{
|
||||
autoCorrectList[i] = autoCorrectList[i].split(",");
|
||||
if(!(autoCorrectList[i][0] == null || autoCorrectList[i][0].length == 0 || autoCorrectList[i][1] == null || autoCorrectList[i][1].length == 0))
|
||||
{
|
||||
_spellingCorrections[StringUtil.trim(autoCorrectList[i][0])] = StringUtil.trim(autoCorrectList[i][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function onEmoticonDefsLoaded(ed:DefPacksDefHelper) : void
|
||||
{
|
||||
var currObj:Object = null;
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_EMOTICON] = null;
|
||||
var data:Object = ed.def;
|
||||
var emoteDefs:Object = new Object();
|
||||
for each(currObj in data)
|
||||
{
|
||||
emoteDefs[currObj.id] = int(currObj.mediaRef);
|
||||
}
|
||||
_emoteDefs = emoteDefs;
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
}
|
||||
|
||||
public static function set playerSfsUserId(s:int) : void
|
||||
{
|
||||
_playerSfsUserId = s;
|
||||
}
|
||||
|
||||
public static function getEmoticonMediaId(defId:int) : int
|
||||
{
|
||||
if(!_emoteDefs[defId])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return _emoteDefs[defId];
|
||||
}
|
||||
|
||||
public static function getEmoticonDefId(mediaId:int) : int
|
||||
{
|
||||
var defId:String = null;
|
||||
for(defId in _emoteDefs)
|
||||
{
|
||||
if(_emoteDefs[defId] == mediaId)
|
||||
{
|
||||
return int(defId);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function addChatMessage(msg:String) : void
|
||||
{
|
||||
_chatHist.addMessage(gMainFrame.userInfo.playerAvatarInfo.avName,gMainFrame.userInfo.playerAvatarInfo.userName,msg);
|
||||
}
|
||||
|
||||
public static function sendAvatarSafeChat(sctString:String, sctCode:String, pressSafeChatBtn:Boolean = true) : void
|
||||
{
|
||||
if(Boolean(gMainFrame.clientInfo.invisMode))
|
||||
{
|
||||
return;
|
||||
}
|
||||
AvatarManager.addAvatarMessage(sctString,_playerSfsUserId,0);
|
||||
addChatMessage(sctString);
|
||||
gMainFrame.server.sendMessage(sctCode + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_SAFE);
|
||||
if(_chatHist.enableFreeChatValue)
|
||||
{
|
||||
_chatHist.resetTreeSearch();
|
||||
_chatHist.chatMsgText.text = "";
|
||||
_chatHist.setFocusOnMsgText();
|
||||
}
|
||||
if(pressSafeChatBtn)
|
||||
{
|
||||
GuiManager.safeChatBtnDownHandler(null);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendAvatarEmote(emote:Sprite) : void
|
||||
{
|
||||
if(Boolean(gMainFrame.clientInfo.invisMode))
|
||||
{
|
||||
return;
|
||||
}
|
||||
AvatarManager.setAvatarEmote(emote);
|
||||
if(!EmoticonUtility.getEmoteString(emote))
|
||||
{
|
||||
throw new Error("setAvatarEmote: sent invalid emote sprite?!");
|
||||
}
|
||||
addChatMessage(EmoticonUtility.getEmoteString(emote));
|
||||
gMainFrame.server.sendMessage(EmoticonUtility.idForEmote(emote) + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_EMOTE);
|
||||
if(_chatHist.enableFreeChatValue)
|
||||
{
|
||||
_chatHist.resetTreeSearch();
|
||||
_chatHist.chatMsgText.text = "";
|
||||
_chatHist.setFocusOnMsgText();
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendAvatarAction(action:Sprite) : void
|
||||
{
|
||||
if(Boolean(gMainFrame.clientInfo.invisMode))
|
||||
{
|
||||
return;
|
||||
}
|
||||
AvatarManager.setAvatarAction(action);
|
||||
if(!_actionMgr.getActionString(action))
|
||||
{
|
||||
throw new Error("setAvatarAction: sent invalid action sprite?!");
|
||||
}
|
||||
addChatMessage(_actionMgr.getActionString(action));
|
||||
var avView:AvatarWorldView = AvatarManager.avatarViewList[AvatarManager.playerSfsUserId];
|
||||
var packAnimFlip:int = avView.lastIdleAnim;
|
||||
gMainFrame.server.sendMessage(_actionMgr.getActionString(action) + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_ACTION + RAW_STR + packAnimFlip);
|
||||
if(_chatHist.enableFreeChatValue)
|
||||
{
|
||||
_chatHist.resetTreeSearch();
|
||||
_chatHist.chatMsgText.text = "";
|
||||
_chatHist.setFocusOnMsgText();
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendAvatarAttachmentEmot(emotDefId:int, extra:String = null) : void
|
||||
{
|
||||
if(Boolean(gMainFrame.clientInfo.invisMode))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(extra == null)
|
||||
{
|
||||
extra = "";
|
||||
}
|
||||
gMainFrame.server.sendMessage(emotDefId + "," + extra + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_ATTACHMENT);
|
||||
}
|
||||
|
||||
public static function sendAvatarBlendColor(c:uint) : void
|
||||
{
|
||||
gMainFrame.server.sendMessage(int(c) + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_BLEND_COLOR);
|
||||
}
|
||||
|
||||
public static function sendAvatarAlphaLevel(a:uint) : void
|
||||
{
|
||||
gMainFrame.server.sendMessage(int(a) + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_ALPHA_LEVEL);
|
||||
}
|
||||
|
||||
public static function sendChatMessage(senderId:int, msg:String, inGame:Boolean) : void
|
||||
{
|
||||
if(Boolean(gMainFrame.clientInfo.invisMode) || !Utility.canChat())
|
||||
{
|
||||
return;
|
||||
}
|
||||
msg = fixMispellings(msg);
|
||||
msg = adjustCamelCase(msg);
|
||||
AvatarManager.addAvatarMessage("...",senderId,0);
|
||||
msg = adjustSpecialWords(msg);
|
||||
var chatType:int = gMainFrame.userInfo.sgChatType == ChatHistory.SG_CHAT_TYPE_FREE ? CHAT_TYPE_TYPED : CHAT_TYPE_LIMITED;
|
||||
gMainFrame.server.sendMessage(msg + RAW_STR + int(inGame) + RAW_STR + chatType);
|
||||
if(_chatHist.enableFreeChatValue)
|
||||
{
|
||||
_chatHist.resetTreeSearch();
|
||||
_chatHist.chatMsgText.text = "";
|
||||
gMainFrame.stage.focus = _chatHist.chatMsgText;
|
||||
}
|
||||
}
|
||||
|
||||
private static function adjustSpecialWords(msg:String) : String
|
||||
{
|
||||
var currWord:String = null;
|
||||
var currWordLowerCase:String = null;
|
||||
var specialWord:String = null;
|
||||
var idx:int = 0;
|
||||
var prev:String = null;
|
||||
var word:String = null;
|
||||
var post:String = null;
|
||||
_replacedWords = {};
|
||||
var words:Array = msg.split(" ");
|
||||
var caseType:int = 0;
|
||||
for(var i:int = 0; i < words.length; i++)
|
||||
{
|
||||
currWord = words[i];
|
||||
currWordLowerCase = currWord.toLowerCase();
|
||||
for(specialWord in _specialWords)
|
||||
{
|
||||
idx = currWordLowerCase.indexOf(specialWord);
|
||||
if(idx >= 0)
|
||||
{
|
||||
prev = currWord.substr(0,idx);
|
||||
word = currWord.substr(idx,specialWord.length);
|
||||
post = currWord.substr(idx + specialWord.length);
|
||||
caseType = getCaseType(word);
|
||||
word = setCaseType(_specialWords[specialWord],caseType);
|
||||
words[i] = prev + word + post;
|
||||
_replacedWords[words[i]] = currWord;
|
||||
}
|
||||
}
|
||||
}
|
||||
return words.join(" ");
|
||||
}
|
||||
|
||||
private static function getCaseType(word:String) : int
|
||||
{
|
||||
if(word.toLowerCase() == word)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var firstLetter:String = word.charAt(0);
|
||||
var numCaps:int = int(word.match(/[A-Z]/g).length);
|
||||
if(numCaps == word.length)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
private static function setCaseType(word:String, caseType:int) : String
|
||||
{
|
||||
if(caseType == 0)
|
||||
{
|
||||
return word.toLowerCase();
|
||||
}
|
||||
if(caseType == 1)
|
||||
{
|
||||
return word.toUpperCase();
|
||||
}
|
||||
word = word.toLowerCase();
|
||||
var firstLetter:String = word.charAt(0).toUpperCase();
|
||||
return firstLetter + word.substr(1);
|
||||
}
|
||||
|
||||
private static function reverseSpecialWords(msg:String) : String
|
||||
{
|
||||
var currWord:String = null;
|
||||
if(_replacedWords == null)
|
||||
{
|
||||
return msg;
|
||||
}
|
||||
var words:Array = msg.split(" ");
|
||||
for(var i:int = 0; i < words.length; i++)
|
||||
{
|
||||
currWord = words[i].toLowerCase();
|
||||
if(!(_replacedWords[currWord] == null || currWord == "constructor"))
|
||||
{
|
||||
words[i] = _replacedWords[currWord];
|
||||
}
|
||||
}
|
||||
_replacedWords = null;
|
||||
return words.join(" ");
|
||||
}
|
||||
|
||||
private static function adjustCamelCase(msg:String) : String
|
||||
{
|
||||
var numCaps:int = 0;
|
||||
var word:String = null;
|
||||
var lettersOnly:String = null;
|
||||
var firstLetter:String = null;
|
||||
var firstLetterIdx:int = 0;
|
||||
var words:Array = msg.split(" ");
|
||||
for(var i:int = 0; i < words.length; i++)
|
||||
{
|
||||
word = words[i];
|
||||
lettersOnly = word.match(/[a-zA-Z]/g).join("");
|
||||
firstLetter = lettersOnly.charAt(0);
|
||||
numCaps = int(lettersOnly.match(/[A-Z]/g).length);
|
||||
if(numCaps > 0 && numCaps != lettersOnly.length)
|
||||
{
|
||||
if(firstLetter.match(/[A-z]/g).length == 1)
|
||||
{
|
||||
firstLetterIdx = getIndexOfFirstLetter(word,lettersOnly);
|
||||
words[i] = word.substr(0,firstLetterIdx) + firstLetter + word.toLowerCase().substr(firstLetterIdx + 1,word.length);
|
||||
}
|
||||
else
|
||||
{
|
||||
words[i] = word.toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
return words.join(" ");
|
||||
}
|
||||
|
||||
public static function getFirstLetter(msg:String) : String
|
||||
{
|
||||
var lettersOnly:String = msg.match(/[a-zA-Z]/g).join("");
|
||||
if(lettersOnly.length > 0)
|
||||
{
|
||||
return lettersOnly.charAt(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getIndexOfFirstLetter(msg:String, lettersOnly:String) : int
|
||||
{
|
||||
if(lettersOnly == "")
|
||||
{
|
||||
lettersOnly = msg.match(/[a-zA-Z]/g).join();
|
||||
}
|
||||
for(var i:int = 0; i < msg.length; i++)
|
||||
{
|
||||
if(msg.charAt(i) == lettersOnly.charAt(0))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static function fixMispellings(msg:String) : String
|
||||
{
|
||||
var word:String = null;
|
||||
if(!_spellingCorrections || LocalizationManager.currentLanguage != LocalizationManager.LANG_ENG)
|
||||
{
|
||||
return msg;
|
||||
}
|
||||
var words:Array = msg.split(" ");
|
||||
for(var i:int = 0; i < words.length; i++)
|
||||
{
|
||||
word = words[i].toLowerCase();
|
||||
word = stripPunctuation(word);
|
||||
if(_spellingCorrections[word] != null)
|
||||
{
|
||||
word = _spellingCorrections[word];
|
||||
words[i] = word;
|
||||
}
|
||||
}
|
||||
return words.join(" ");
|
||||
}
|
||||
|
||||
public static function stripPunctuation(word:String) : String
|
||||
{
|
||||
return word.replace(/[^A-Za-z0-9 ']+/g,"");
|
||||
}
|
||||
|
||||
public static function sendAvatarSlide(name:String) : void
|
||||
{
|
||||
if(Boolean(gMainFrame.clientInfo.invisMode))
|
||||
{
|
||||
return;
|
||||
}
|
||||
gMainFrame.server.sendMessage(name + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_SLIDE);
|
||||
}
|
||||
|
||||
public static function sendPermEmote(emoteMediaId:int, inGame:Boolean) : void
|
||||
{
|
||||
gMainFrame.server.sendMessage(emoteMediaId + RAW_STR + int(inGame) + RAW_STR + CHAT_TYPE_PERM_EMOTE);
|
||||
}
|
||||
|
||||
public static function sendPetAction(petActionId:int, extraId:int = 0) : void
|
||||
{
|
||||
gMainFrame.server.sendMessage(petActionId + "," + extraId + RAW_STR + int(MinigameManager.inMinigame) + RAW_STR + CHAT_TYPE_PET_ACTION);
|
||||
}
|
||||
|
||||
public static function sendCustomAdventureMessage(show:Boolean) : void
|
||||
{
|
||||
gMainFrame.server.sendMessage((show ? "on" : "off") + RAW_STR + 0 + RAW_STR + CHAT_TYPE_CUST_ADVENTURE);
|
||||
}
|
||||
|
||||
public static function sendCustomPVPMessage(show:Boolean, gameDefId:int) : void
|
||||
{
|
||||
gMainFrame.server.sendMessage((show ? "on" : "off") + RAW_STR + 0 + RAW_STR + CHAT_TYPE_CUST_PVP + RAW_STR + gameDefId);
|
||||
}
|
||||
|
||||
public static function onSendMessage(evt:MouseEvent, myMsg:String = "") : void
|
||||
{
|
||||
var acts:Sprite = null;
|
||||
var scc:String = null;
|
||||
if(_playerSfsUserId == -1)
|
||||
{
|
||||
DebugUtility.debugTrace("WARNING - UserCommXtCommManager.init was never called or the playerAvatarId is bad");
|
||||
_playerSfsUserId = AvatarManager.playerSfsUserId;
|
||||
}
|
||||
var msg:String = myMsg == "" ? _mainHud.chatBar.text01_chat.text : myMsg;
|
||||
msg = msg.split("\r").join("");
|
||||
msg = msg.split(RAW_STR).join("");
|
||||
msg = StringUtil.trim(msg);
|
||||
if(msg.length <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var es:Object = EmoticonUtility.matchEmoteString(msg);
|
||||
if(Boolean(es.status))
|
||||
{
|
||||
if(Boolean(es.sprite))
|
||||
{
|
||||
sendAvatarEmote(es.sprite);
|
||||
AvatarManager.setAvatarEmote(es.sprite,-2);
|
||||
}
|
||||
else
|
||||
{
|
||||
acts = _actionMgr.matchActionString(msg);
|
||||
if(Boolean(acts))
|
||||
{
|
||||
sendAvatarAction(acts);
|
||||
AvatarManager.setAvatarAction(acts,-2);
|
||||
}
|
||||
else
|
||||
{
|
||||
scc = SafeChatManager.safeChatCodeForString(msg);
|
||||
if(Boolean(scc))
|
||||
{
|
||||
sendAvatarSafeChat(msg,scc,false);
|
||||
AvatarManager.addAvatarMessage(msg,_playerSfsUserId,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendChatMessage(_playerSfsUserId,msg,MinigameManager.inMinigame());
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
_chatHist.resetTreeSearch();
|
||||
_chatHist.chatMsgText.text = "";
|
||||
gMainFrame.stage.focus = _chatHist.chatMsgText;
|
||||
}
|
||||
|
||||
public static function handleXtReply(evt:SFEvent) : void
|
||||
{
|
||||
var data:Array = evt.obj;
|
||||
switch(data[0])
|
||||
{
|
||||
case "uc":
|
||||
userCommChatResponse(data);
|
||||
break;
|
||||
case "ua":
|
||||
userCommAdminMessageResponse(data);
|
||||
break;
|
||||
default:
|
||||
throw new Error("UserCommXtCommManager illegal data:" + data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static function userCommChatResponse(data:Array) : void
|
||||
{
|
||||
var msg:String = null;
|
||||
var permEmoteMediaId:int = 0;
|
||||
var petMsgSplit:Array = null;
|
||||
var split:Array = null;
|
||||
var adventureInfoSplit:Array = null;
|
||||
var questScriptDef:Object = null;
|
||||
var splitData:Array = null;
|
||||
var jmi:MinigameInfo = null;
|
||||
var badChat:Boolean = false;
|
||||
var scm:String = null;
|
||||
var es:Sprite = null;
|
||||
var cacts:Sprite = null;
|
||||
var msgSplit:Array = null;
|
||||
var attId:int = 0;
|
||||
var chattyAv:Avatar = null;
|
||||
var splitMessage:Array = null;
|
||||
var chattyUserId:int = int(data[2]);
|
||||
var inGame:Boolean = Boolean(int(data[4]));
|
||||
var chatType:int = int(data[5]);
|
||||
var showChatterMsg:Boolean = true;
|
||||
if(showChatterMsg)
|
||||
{
|
||||
if(chatType == CHAT_TYPE_PERM_EMOTE)
|
||||
{
|
||||
permEmoteMediaId = int(data[3]);
|
||||
if(permEmoteMediaId >= 0)
|
||||
{
|
||||
AvatarManager.setAvatarEmote(null,chattyUserId,permEmoteMediaId);
|
||||
}
|
||||
else
|
||||
{
|
||||
AvatarManager.setChatBalloonReadyForClear(chattyUserId);
|
||||
}
|
||||
}
|
||||
else if(chatType == CHAT_TYPE_SLIDE)
|
||||
{
|
||||
if(chattyUserId != gMainFrame.server.userId)
|
||||
{
|
||||
_roomMgr.attachAvatarToSlide(AvatarManager.avatarViewList[chattyUserId],data[3]);
|
||||
}
|
||||
}
|
||||
else if(chatType == CHAT_TYPE_PET_ACTION)
|
||||
{
|
||||
petMsgSplit = data[3].split(",");
|
||||
AvatarManager.setPetAction(chattyUserId,petMsgSplit[0],petMsgSplit[1]);
|
||||
}
|
||||
else if(chatType == CHAT_TYPE_CUST_ADVENTURE)
|
||||
{
|
||||
msg = data[3];
|
||||
if(msg == "off")
|
||||
{
|
||||
AvatarManager.addCustomAdventureMessage("","off",chattyUserId,0,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
split = msg.split("|");
|
||||
adventureInfoSplit = split[0].split(",");
|
||||
questScriptDef = QuestXtCommManager.getScriptDef(adventureInfoSplit[0]);
|
||||
if(Boolean(questScriptDef))
|
||||
{
|
||||
AvatarManager.addCustomAdventureMessage(LocalizationManager.translateIdOnly(questScriptDef.titleStrId),split[1] + "|" + adventureInfoSplit[0],chattyUserId,adventureInfoSplit[2],int(data[6]));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(chatType == CHAT_TYPE_CUST_PVP)
|
||||
{
|
||||
msg = data[3];
|
||||
splitData = data[3].split("|");
|
||||
if(splitData[0] == "off")
|
||||
{
|
||||
if(chattyUserId == AvatarManager.playerSfsUserId)
|
||||
{
|
||||
MinigameManager.readySelfForPvpGame({"typeDefId":splitData[1]},splitData[2],true,true);
|
||||
}
|
||||
AvatarManager.addCustomPvpMessage("",splitData[0],chattyUserId,0,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
jmi = MinigameManager.minigameInfoCache.getMinigameInfo(splitData[1]);
|
||||
AvatarManager.addCustomPvpMessage(LocalizationManager.translateIdOnly(jmi.titleStrId),msg,chattyUserId,0,int(data[6]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = data[3];
|
||||
badChat = false;
|
||||
if(chatType == CHAT_TYPE_SAFE)
|
||||
{
|
||||
scm = SafeChatManager.safeChatStringForCode(msg);
|
||||
if(Boolean(scm))
|
||||
{
|
||||
msg = scm;
|
||||
}
|
||||
else
|
||||
{
|
||||
badChat = true;
|
||||
}
|
||||
}
|
||||
if(!badChat)
|
||||
{
|
||||
switch(chatType)
|
||||
{
|
||||
case CHAT_TYPE_TYPED:
|
||||
case CHAT_TYPE_LIMITED:
|
||||
case CHAT_TYPE_SAFE:
|
||||
msg = adjustCamelCase(msg);
|
||||
if(chattyUserId == gMainFrame.server.userId)
|
||||
{
|
||||
msg = reverseSpecialWords(msg);
|
||||
}
|
||||
AvatarManager.addAvatarMessage(msg,chattyUserId,int(data[6]));
|
||||
break;
|
||||
case CHAT_TYPE_EMOTE:
|
||||
es = EmoticonUtility.emoteForId(int(msg));
|
||||
if(Boolean(es))
|
||||
{
|
||||
AvatarManager.setAvatarEmote(es,chattyUserId);
|
||||
}
|
||||
else
|
||||
{
|
||||
badChat = true;
|
||||
}
|
||||
msg = EmoticonUtility.stringForId(int(msg));
|
||||
break;
|
||||
case CHAT_TYPE_ACTION:
|
||||
cacts = _actionMgr.matchActionString(msg);
|
||||
if(Boolean(cacts))
|
||||
{
|
||||
AvatarManager.setAvatarAction(cacts,chattyUserId);
|
||||
}
|
||||
else
|
||||
{
|
||||
badChat = true;
|
||||
}
|
||||
break;
|
||||
case CHAT_TYPE_ATTACHMENT:
|
||||
msgSplit = msg.split(",");
|
||||
attId = int(msgSplit[0]);
|
||||
AvatarManager._setAvatarAttachmentEmot(attId,msgSplit[1],chattyUserId);
|
||||
break;
|
||||
case CHAT_TYPE_BLEND_COLOR:
|
||||
AvatarManager._setAvatarBlendColor(chattyUserId,uint(data[3]));
|
||||
return;
|
||||
case CHAT_TYPE_ALPHA_LEVEL:
|
||||
AvatarManager._setAvatarAlphaLevel(chattyUserId,uint(data[3]));
|
||||
return;
|
||||
default:
|
||||
badChat = true;
|
||||
}
|
||||
}
|
||||
if(badChat)
|
||||
{
|
||||
DebugUtility.debugTrace("WARNING - got bad chat! msg:" + msg + " chatType:" + chatType + " from userId:" + chattyUserId);
|
||||
return;
|
||||
}
|
||||
if(chatType != CHAT_TYPE_ATTACHMENT)
|
||||
{
|
||||
if(Boolean(gMainFrame.clientInfo.extCallsActive))
|
||||
{
|
||||
chattyAv = AvatarManager.getAvatarBySfsUserId(chattyUserId);
|
||||
DebugUtility.debugTrace("mrc:sending cm command - chattyUserId:" + chattyUserId + " chattyAv:" + chattyAv);
|
||||
if(int(data[6]) == 2)
|
||||
{
|
||||
splitMessage = msg.split("|");
|
||||
splitMessage.splice(0,1);
|
||||
msg = splitMessage.join("|");
|
||||
}
|
||||
ExternalInterface.call("mrc",["cm",chattyAv.userName,msg,int(data[6])]);
|
||||
DebugUtility.debugTrace("mrc:cm command sent - chattyUserName:" + chattyAv.userName + " msg:" + msg);
|
||||
}
|
||||
if((chattyUserId != gMainFrame.server.userId || chattyUserId == gMainFrame.server.userId && (chatType == CHAT_TYPE_TYPED || chatType == CHAT_TYPE_LIMITED)) && int(data[6]) <= 1)
|
||||
{
|
||||
_chatHist.addMessageById(chattyUserId,msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function userCommAdminMessageResponse(data:Array) : void
|
||||
{
|
||||
var jcDefHelper:JCDefHelper = null;
|
||||
var msgSplit:Array = null;
|
||||
var isSystemMsg:Boolean = false;
|
||||
var adminMsg:String = data[1];
|
||||
if(adminMsg == "__ABSU_CBS__")
|
||||
{
|
||||
jcDefHelper = new JCDefHelper();
|
||||
jcDefHelper.deleteIndexFileFromCache();
|
||||
jcDefHelper.destroy();
|
||||
jcDefHelper = null;
|
||||
GuiManager.refreshJammerCentral();
|
||||
}
|
||||
else
|
||||
{
|
||||
msgSplit = adminMsg.split("|");
|
||||
if(msgSplit.length > 1)
|
||||
{
|
||||
adminMsg = LocalizationManager.translateIdAndInsertOnly(msgSplit[0],msgSplit.slice(1));
|
||||
}
|
||||
isSystemMsg = data[2] == null || int(data[2]) == 1;
|
||||
if(!isSystemMsg)
|
||||
{
|
||||
gMainFrame.clientInfo.lastBroadcastMessage = adminMsg;
|
||||
GuiManager.updateSettingsMessage();
|
||||
}
|
||||
if(isSystemMsg || !gMainFrame.isInMinigame() && gMainFrame.clientInfo.roomType != Utility.ROOMTYPE_QUEST)
|
||||
{
|
||||
new SBAJOkPopup(GuiManager.guiLayer,adminMsg);
|
||||
}
|
||||
_chatHist.addPrivateMessage(LocalizationManager.translateIdOnly(15964),null,adminMsg);
|
||||
}
|
||||
}
|
||||
|
||||
private static function getSpecialFormat() : TextFormat
|
||||
{
|
||||
var specialFormat:TextFormat = new TextFormat();
|
||||
specialFormat.color = 12845056;
|
||||
specialFormat.bold = true;
|
||||
return specialFormat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
package avatar
|
||||
{
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class UserInfo
|
||||
{
|
||||
|
||||
public var userName:String;
|
||||
|
||||
public var currPerUserAvId:int;
|
||||
|
||||
public var avList:Object;
|
||||
|
||||
public var denItemsFull:Array;
|
||||
|
||||
public var denItemsPartial:Array;
|
||||
|
||||
public var accountType:int;
|
||||
|
||||
public var nameBarData:int;
|
||||
|
||||
public var isGuide:Boolean;
|
||||
|
||||
public var userNameModeratedFlag:int;
|
||||
|
||||
private var _allItems:Array;
|
||||
|
||||
private var _achievements:Array;
|
||||
|
||||
private var _timeStampSinceLastRequest:Number;
|
||||
|
||||
public function UserInfo()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(initUserName:String, initAvList:Array = null, initCurrPerUserAvId:int = -1, initAccountType:int = 1, initUserNameModerated:int = 0) : void
|
||||
{
|
||||
this.userName = initUserName;
|
||||
this._timeStampSinceLastRequest = 0;
|
||||
this._allItems = [];
|
||||
if(Boolean(initAvList))
|
||||
{
|
||||
this.avList = initAvList;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.avList = {};
|
||||
}
|
||||
if(initCurrPerUserAvId > 0)
|
||||
{
|
||||
this.currPerUserAvId = initCurrPerUserAvId;
|
||||
}
|
||||
this.accountType = initAccountType;
|
||||
this.userNameModeratedFlag = initUserNameModerated;
|
||||
}
|
||||
|
||||
public function addAvatarToList(avatarInfo:AvatarInfo) : void
|
||||
{
|
||||
this.avList[avatarInfo.perUserAvId] = avatarInfo;
|
||||
}
|
||||
|
||||
public function getAvatarInfoByPerUserAvId(perUserAvId:int) : AvatarInfo
|
||||
{
|
||||
if(perUserAvId == -1)
|
||||
{
|
||||
return this.avList[this.currPerUserAvId];
|
||||
}
|
||||
if(Boolean(this.avList[perUserAvId]))
|
||||
{
|
||||
return this.avList[perUserAvId];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function addAchievementsTolist(achievs:Array) : void
|
||||
{
|
||||
if(!this._achievements)
|
||||
{
|
||||
this._achievements = [];
|
||||
}
|
||||
var j:int = int(this._achievements.length);
|
||||
for(var i:int = 0; i < achievs.length; i++)
|
||||
{
|
||||
this._achievements[j++] = achievs[i];
|
||||
}
|
||||
}
|
||||
|
||||
public function set fullItemList(a:Array) : void
|
||||
{
|
||||
this._allItems = a;
|
||||
}
|
||||
|
||||
public function get fullItemList() : Array
|
||||
{
|
||||
return this._allItems;
|
||||
}
|
||||
|
||||
public function getFullItemList(withBodyMods:Boolean) : Array
|
||||
{
|
||||
var items:Array = [];
|
||||
for(var i:int = 0; i < this._allItems.length; i++)
|
||||
{
|
||||
if(withBodyMods)
|
||||
{
|
||||
items.push(this._allItems[i]);
|
||||
}
|
||||
else if(this._allItems[i].invIdx >= 0)
|
||||
{
|
||||
items.push(this._allItems[i]);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public function getPartialItemList(avType:int, withBodyMods:Boolean) : Array
|
||||
{
|
||||
var items:Array = [];
|
||||
for(var i:int = 0; i < this._allItems.length; i++)
|
||||
{
|
||||
if(this._allItems[i].invIdx < 0 && withBodyMods || Utility.isSameEnviroType(gMainFrame.userInfo.getAvatarEnviroTypeFlagByAvType(avType),this._allItems[i].enviroType))
|
||||
{
|
||||
if(withBodyMods)
|
||||
{
|
||||
items.push(this._allItems[i]);
|
||||
}
|
||||
else if(this._allItems[i].invIdx >= 0)
|
||||
{
|
||||
items.push(this._allItems[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public function allItemsInUseOff(perUserAvId:int) : void
|
||||
{
|
||||
for(var i:int = 0; i < this._allItems.length; i++)
|
||||
{
|
||||
this._allItems[i].setInUse(perUserAvId,false);
|
||||
}
|
||||
}
|
||||
|
||||
public function get achievements() : Array
|
||||
{
|
||||
return this._achievements;
|
||||
}
|
||||
|
||||
public function get isMember() : Boolean
|
||||
{
|
||||
return Utility.isMember(this.accountType);
|
||||
}
|
||||
|
||||
public function resetAchievements() : void
|
||||
{
|
||||
this._achievements = [];
|
||||
}
|
||||
|
||||
public function getTimeOfLastAchievementRequest() : Number
|
||||
{
|
||||
return this._timeStampSinceLastRequest;
|
||||
}
|
||||
|
||||
public function setTimeOfLastAchievementRequest(time:Number) : void
|
||||
{
|
||||
this._timeStampSinceLastRequest = time;
|
||||
}
|
||||
|
||||
public function getModeratedUserName() : String
|
||||
{
|
||||
if(this.userNameModeratedFlag > 0)
|
||||
{
|
||||
return this.userName;
|
||||
}
|
||||
return LocalizationManager.translateIdOnly(LocalizationManager.NEW_JAMMER_USERNAME);
|
||||
}
|
||||
|
||||
public function getAccountType() : int
|
||||
{
|
||||
return this.accountType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,385 @@
|
||||
package avatar
|
||||
{
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import flash.utils.Dictionary;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class UserInfoCache
|
||||
{
|
||||
|
||||
public var myUserName:String;
|
||||
|
||||
public var myBuddyCount:int;
|
||||
|
||||
public var isMember:Boolean;
|
||||
|
||||
public var isModerator:Boolean;
|
||||
|
||||
public var isGuide:Boolean;
|
||||
|
||||
public var isSilenced:Boolean;
|
||||
|
||||
public var isMyDenPrivate:Boolean;
|
||||
|
||||
public var sgChatType:int;
|
||||
|
||||
public var sgChatTypeNonDegraded:int;
|
||||
|
||||
public var firstFiveMinutes:int;
|
||||
|
||||
public var pendingFlags:Number;
|
||||
|
||||
public var activeDenRoomInvId:int;
|
||||
|
||||
public var numLogins:int;
|
||||
|
||||
public var worldMapRoomName:String;
|
||||
|
||||
public var avtDefsCached:Boolean;
|
||||
|
||||
private var _userInfo:Object;
|
||||
|
||||
private var _perUserAvIdToUserName:Dictionary;
|
||||
|
||||
private var _myPerUserAvId:int;
|
||||
|
||||
private var _myUserVarCache:UserVarCache;
|
||||
|
||||
private var _avatarDefs:Object;
|
||||
|
||||
private var _denRoomDefs:Object;
|
||||
|
||||
private var _genericListDefsInfo:Object;
|
||||
|
||||
private var _myTradeList:Array;
|
||||
|
||||
private var _myPetsInDen:Array;
|
||||
|
||||
public function UserInfoCache()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init() : void
|
||||
{
|
||||
this._userInfo = {};
|
||||
this._myPerUserAvId = -1;
|
||||
this.myUserName = "";
|
||||
this.avtDefsCached = false;
|
||||
this._myUserVarCache = new UserVarCache();
|
||||
this._myUserVarCache.init();
|
||||
this._perUserAvIdToUserName = new Dictionary(true);
|
||||
this._avatarDefs = new Object();
|
||||
this._genericListDefsInfo = new Object();
|
||||
this._myTradeList = [];
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
this._userInfo = null;
|
||||
this._avatarDefs = null;
|
||||
this._denRoomDefs = null;
|
||||
this._genericListDefsInfo = null;
|
||||
this._myTradeList = null;
|
||||
}
|
||||
|
||||
public function getUserInfoByUserName(userName:String) : UserInfo
|
||||
{
|
||||
return this._userInfo[userName];
|
||||
}
|
||||
|
||||
public function setUserInfoByUserName(userNameParam:String, userInfoParam:UserInfo) : void
|
||||
{
|
||||
var info:UserInfo = null;
|
||||
var avInfo:AvatarInfo = null;
|
||||
if(Boolean(userNameParam) && userNameParam != "")
|
||||
{
|
||||
info = this._userInfo[userNameParam] = userInfoParam;
|
||||
for each(avInfo in info.avList)
|
||||
{
|
||||
this._perUserAvIdToUserName[avInfo.perUserAvId] = userNameParam;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getAvatarInfoByUsernamePerUserAvId(userName:String, perUserAvId:int) : AvatarInfo
|
||||
{
|
||||
var user:UserInfo = null;
|
||||
var avInfo:AvatarInfo = null;
|
||||
loop0:
|
||||
for each(user in this._userInfo)
|
||||
{
|
||||
var _loc7_:int = 0;
|
||||
var _loc8_:* = user.avList;
|
||||
do
|
||||
{
|
||||
for each(avInfo in _loc8_)
|
||||
{
|
||||
}
|
||||
continue loop0;
|
||||
}
|
||||
while(!(avInfo.userName == userName && avInfo.perUserAvId == perUserAvId));
|
||||
return avInfo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function changeUserName(oldUserName:String, newUserName:String, userNameModeratedFlag:int) : void
|
||||
{
|
||||
var info:UserInfo = null;
|
||||
var avInfo:AvatarInfo = null;
|
||||
if(this._userInfo.hasOwnProperty(oldUserName))
|
||||
{
|
||||
info = this._userInfo[oldUserName];
|
||||
this._userInfo[newUserName] = info;
|
||||
this._userInfo[newUserName].userName = newUserName;
|
||||
this._userInfo[newUserName].userNameModeratedFlag = userNameModeratedFlag;
|
||||
for each(avInfo in info.avList)
|
||||
{
|
||||
avInfo.userName = newUserName;
|
||||
this._perUserAvIdToUserName[avInfo.perUserAvId] = newUserName;
|
||||
}
|
||||
delete this._userInfo[oldUserName];
|
||||
}
|
||||
}
|
||||
|
||||
public function getAvatarInfoByUserName(userName:String) : AvatarInfo
|
||||
{
|
||||
if(this._userInfo.hasOwnProperty(userName))
|
||||
{
|
||||
return this._userInfo[userName].avList[this._userInfo[userName].currPerUserAvId];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAvatarInfoByUserNameThenPerUserAvId(userName:String, perUserAvId:int) : AvatarInfo
|
||||
{
|
||||
var test:Object = null;
|
||||
if(this._userInfo.hasOwnProperty(userName))
|
||||
{
|
||||
test = this._userInfo[userName];
|
||||
return this._userInfo[userName].avList[perUserAvId];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get myPerUserAvId() : int
|
||||
{
|
||||
return this._myPerUserAvId;
|
||||
}
|
||||
|
||||
public function setCurrAvDbId(userName:String, currAvDbId:int) : void
|
||||
{
|
||||
if(this._userInfo.hasOwnProperty(userName))
|
||||
{
|
||||
this._userInfo[userName].currPerUserAvId = currAvDbId;
|
||||
}
|
||||
}
|
||||
|
||||
public function set myPerUserAvId(setperUserAvId:int) : void
|
||||
{
|
||||
this._myPerUserAvId = setperUserAvId;
|
||||
if(this._userInfo.hasOwnProperty(this.myUserName) && Boolean(this._userInfo[this.myUserName]))
|
||||
{
|
||||
UserInfo(this._userInfo[this.myUserName]).currPerUserAvId = setperUserAvId;
|
||||
}
|
||||
}
|
||||
|
||||
public function setAvatarInfoByUsernamePerUserAvId(perUserAvId:int, setAvatarInfo:AvatarInfo, updateCurrperUserAvId:Boolean = false) : void
|
||||
{
|
||||
var setAvUsername:String = setAvatarInfo.userName;
|
||||
if(!this._userInfo.hasOwnProperty(setAvUsername))
|
||||
{
|
||||
throw new Error("Invalid setAvatarInfo! Needs userName!");
|
||||
}
|
||||
this._userInfo[setAvUsername].avList[perUserAvId] = setAvatarInfo;
|
||||
if(updateCurrperUserAvId)
|
||||
{
|
||||
this._userInfo[setAvUsername].currPerUserAvId = perUserAvId;
|
||||
this._perUserAvIdToUserName[perUserAvId] = setAvUsername;
|
||||
}
|
||||
}
|
||||
|
||||
public function setAccountTypeByUserName(userName:String, accountType:int) : void
|
||||
{
|
||||
if(this._userInfo.hasOwnProperty(userName))
|
||||
{
|
||||
this._userInfo[userName].accountType = accountType;
|
||||
}
|
||||
}
|
||||
|
||||
public function set playerAvatarInfo(setAvInfo:AvatarInfo) : void
|
||||
{
|
||||
this._myPerUserAvId = setAvInfo.perUserAvId;
|
||||
this.myUserName = setAvInfo.userName;
|
||||
var myUserInfo:UserInfo = UserInfo(this._userInfo[this.myUserName]);
|
||||
if(Boolean(myUserInfo))
|
||||
{
|
||||
myUserInfo.avList[this._myPerUserAvId] = setAvInfo;
|
||||
myUserInfo.currPerUserAvId = this._myPerUserAvId;
|
||||
}
|
||||
}
|
||||
|
||||
public function get playerAvatarInfo() : AvatarInfo
|
||||
{
|
||||
try
|
||||
{
|
||||
return this._userInfo[this.myUserName].avList[this._myPerUserAvId];
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
DebugUtility.debugTrace("Error trying to get playerAvatarInfo! msg:" + e.message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get playerUserInfo() : UserInfo
|
||||
{
|
||||
return this.getUserInfoByUserName(this.myUserName);
|
||||
}
|
||||
|
||||
public function get userVarCache() : UserVarCache
|
||||
{
|
||||
return this._myUserVarCache;
|
||||
}
|
||||
|
||||
public function get userNameModerated() : String
|
||||
{
|
||||
if(gMainFrame.clientInfo.userNameModerated > 0)
|
||||
{
|
||||
return this.myUserName;
|
||||
}
|
||||
return LocalizationManager.translateIdOnly(LocalizationManager.NEW_JAMMER_USERNAME);
|
||||
}
|
||||
|
||||
public function setAvatarDefs(avtDefs:Object) : void
|
||||
{
|
||||
this._avatarDefs = avtDefs;
|
||||
this.avtDefsCached = true;
|
||||
}
|
||||
|
||||
public function getAvatarColorLayer1InfoByAvType(avType:uint) : uint
|
||||
{
|
||||
if(Boolean(this._avatarDefs[avType]))
|
||||
{
|
||||
return this._avatarDefs[avType].colorLayer1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getAvatarColorLayer2InfoByAvType(avType:uint) : uint
|
||||
{
|
||||
if(Boolean(this._avatarDefs[avType]))
|
||||
{
|
||||
return this._avatarDefs[avType].colorLayer2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getAvatarColorLayer3InfoByAvType(avType:uint) : uint
|
||||
{
|
||||
if(Boolean(this._avatarDefs[avType]))
|
||||
{
|
||||
return this._avatarDefs[avType].colorLayer3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getAvatarDefPatternInfoByAvType(avType:int) : uint
|
||||
{
|
||||
if(Boolean(this._avatarDefs[avType]))
|
||||
{
|
||||
return this._avatarDefs[avType].defPattern;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getAvatarDefEyesInfoByAvType(avType:int) : uint
|
||||
{
|
||||
if(Boolean(this._avatarDefs[avType]))
|
||||
{
|
||||
return this._avatarDefs[avType].defEyes;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getAvatarMemberInfoByAvType(avType:int) : Boolean
|
||||
{
|
||||
if(Boolean(this._avatarDefs[avType]))
|
||||
{
|
||||
return this._avatarDefs[avType].isMemOnly;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getAvatarEnviroTypeFlagByAvType(avType:int) : int
|
||||
{
|
||||
if(Boolean(this._avatarDefs[avType]))
|
||||
{
|
||||
return this._avatarDefs[avType].enviroTypeFlag;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getAvatarDefByAvType(avType:int) : Object
|
||||
{
|
||||
return this._avatarDefs[avType];
|
||||
}
|
||||
|
||||
public function set denRoomDefs(o:Object) : void
|
||||
{
|
||||
this._denRoomDefs = o;
|
||||
}
|
||||
|
||||
public function get denRoomDefs() : Object
|
||||
{
|
||||
return this._denRoomDefs;
|
||||
}
|
||||
|
||||
public function getDenRoomDefByDefId(defId:int) : Object
|
||||
{
|
||||
return this._denRoomDefs[defId];
|
||||
}
|
||||
|
||||
public function set genericListDefs(o:Object) : void
|
||||
{
|
||||
this._genericListDefsInfo = o;
|
||||
}
|
||||
|
||||
public function getGenericListDefByDefId(defId:int) : Object
|
||||
{
|
||||
return this._genericListDefsInfo[defId];
|
||||
}
|
||||
|
||||
public function getMyTradeList() : Array
|
||||
{
|
||||
return this._myTradeList;
|
||||
}
|
||||
|
||||
public function set myTradeList(value:Array) : void
|
||||
{
|
||||
this._myTradeList = value;
|
||||
}
|
||||
|
||||
public function removeFromMyTradeList(index:int) : void
|
||||
{
|
||||
this._myTradeList.splice(index,1);
|
||||
}
|
||||
|
||||
public function set myPetsInDen(value:Array) : void
|
||||
{
|
||||
this._myPetsInDen = value;
|
||||
}
|
||||
|
||||
public function get myPetsInDen() : Array
|
||||
{
|
||||
return this._myPetsInDen;
|
||||
}
|
||||
|
||||
public function isPendingFlagSet(bitIdx:int) : Boolean
|
||||
{
|
||||
return (this.pendingFlags & 1 << bitIdx) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package avatar
|
||||
{
|
||||
public class UserVarCache
|
||||
{
|
||||
|
||||
private var _cache:Object;
|
||||
|
||||
public function UserVarCache()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init() : void
|
||||
{
|
||||
this._cache = new Object();
|
||||
}
|
||||
|
||||
public function set playerUserVars(userVars:Object) : void
|
||||
{
|
||||
var userVarId:String = null;
|
||||
this._cache = new Object();
|
||||
for(userVarId in userVars)
|
||||
{
|
||||
this._cache[userVarId] = {
|
||||
"value":userVars[userVarId].value,
|
||||
"type":userVars[userVarId].type
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public function get playerUserVars() : Object
|
||||
{
|
||||
return this._cache;
|
||||
}
|
||||
|
||||
public function getUserVarValueById(userVarDefId:int) : int
|
||||
{
|
||||
if(Boolean(this._cache) && Boolean(this._cache[userVarDefId]))
|
||||
{
|
||||
return this._cache[userVarDefId].value;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function getUserVarTypeById(userVarDefId:int) : int
|
||||
{
|
||||
if(Boolean(this._cache) && Boolean(this._cache[userVarDefId]))
|
||||
{
|
||||
return this._cache[userVarDefId].type;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function isBitSet(userVarDefId:int, bitIdx:int) : Boolean
|
||||
{
|
||||
if(Boolean(this._cache) && Boolean(this._cache[userVarDefId]))
|
||||
{
|
||||
return Boolean(this._cache[userVarDefId].value & 1 << bitIdx);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function numBitsSet(userVarValue:int, numBitsToCheck:int) : int
|
||||
{
|
||||
if(userVarValue == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var numSet:int = 0;
|
||||
for(var i:int = 0; i < numBitsToCheck; i++)
|
||||
{
|
||||
if((userVarValue & 1 << i) != 0)
|
||||
{
|
||||
numSet++;
|
||||
}
|
||||
}
|
||||
return numSet;
|
||||
}
|
||||
|
||||
public function updateUserVar(defId:int, value:int, type:int = -1) : void
|
||||
{
|
||||
if(!this._cache)
|
||||
{
|
||||
this._cache = new Object();
|
||||
}
|
||||
if(Boolean(this._cache[defId]))
|
||||
{
|
||||
this._cache[defId].value = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._cache[defId] = {
|
||||
"value":value,
|
||||
"type":type
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user