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
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,40 @@
|
||||
package quest
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class QuestEvent extends Event
|
||||
{
|
||||
|
||||
public static const LOAD_SFX:String = "QuestEventLoadSfx";
|
||||
|
||||
public static const PLAY_SFX:String = "QuestEventPlaySfx";
|
||||
|
||||
public static const TORCH:String = "QuestEventTorch";
|
||||
|
||||
public static const TRIGGER_CAMERASHAKE:String = "QuestEventTriggerCameraShake";
|
||||
|
||||
private var _secondaryType:String;
|
||||
|
||||
public function QuestEvent(type:String, secondaryType:String = "")
|
||||
{
|
||||
super(type,true,false);
|
||||
this._secondaryType = secondaryType;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new QuestEvent(type);
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return formatToString("QuestEvent",type,this._secondaryType);
|
||||
}
|
||||
|
||||
public function get secondaryType() : String
|
||||
{
|
||||
return this._secondaryType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,31 @@
|
||||
package quest
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import mx.core.MovieClipLoaderAsset;
|
||||
|
||||
[Embed(source="/_assets/assets.swf", symbol="symbol1")]
|
||||
public class QuestManager_torch extends MovieClipLoaderAsset
|
||||
{
|
||||
|
||||
private static var bytes:ByteArray = null;
|
||||
|
||||
public var dataClass:Class = QuestManager_torch_dataClass;
|
||||
|
||||
public function QuestManager_torch()
|
||||
{
|
||||
super();
|
||||
initialWidth = 13880 / 20;
|
||||
initialHeight = 8000 / 20;
|
||||
}
|
||||
|
||||
override public function get movieClipData() : ByteArray
|
||||
{
|
||||
if(bytes == null)
|
||||
{
|
||||
bytes = ByteArray(new this.dataClass());
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package quest
|
||||
{
|
||||
import mx.core.ByteArrayAsset;
|
||||
|
||||
[ExcludeClass]
|
||||
[Embed(source="/_assets/7_quest.QuestManager_torch_dataClass.bin", mimeType="application/octet-stream")]
|
||||
public class QuestManager_torch_dataClass extends ByteArrayAsset
|
||||
{
|
||||
|
||||
public function QuestManager_torch_dataClass()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
package quest
|
||||
{
|
||||
import avatar.AvatarManager;
|
||||
import avatar.AvatarView;
|
||||
import avatar.AvatarWorldView;
|
||||
import com.sbi.graphics.PaletteHelper;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.geom.Point;
|
||||
import item.ItemXtCommManager;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class QuestMelee extends Sprite
|
||||
{
|
||||
|
||||
private var _weaponItem:Object;
|
||||
|
||||
private var _npc:QuestActor;
|
||||
|
||||
private var _mediaHelperObj:MediaHelper;
|
||||
|
||||
private var _swipeMC:MovieClip;
|
||||
|
||||
private var _localPlayerLaunched:Boolean;
|
||||
|
||||
private var _angle:Number;
|
||||
|
||||
private var _timer:Number;
|
||||
|
||||
private var _meleeID:int;
|
||||
|
||||
private var _players:Array;
|
||||
|
||||
private var _color:uint;
|
||||
|
||||
public function QuestMelee(meleeID:int)
|
||||
{
|
||||
super();
|
||||
this._meleeID = meleeID;
|
||||
}
|
||||
|
||||
public function get angle() : Number
|
||||
{
|
||||
return this._angle;
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
if(this._mediaHelperObj != null)
|
||||
{
|
||||
this._mediaHelperObj.destroy();
|
||||
this._mediaHelperObj = null;
|
||||
}
|
||||
if(parent != null)
|
||||
{
|
||||
parent.removeChild(this);
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(inFrameTime:Number) : Boolean
|
||||
{
|
||||
var collisionPoint:Point = null;
|
||||
var hitActors:Array = null;
|
||||
var questActor:QuestActor = null;
|
||||
var i:int = 0;
|
||||
var avView:AvatarWorldView = null;
|
||||
var hitX:Number = NaN;
|
||||
var hitY:Number = NaN;
|
||||
if(this._timer > 0)
|
||||
{
|
||||
this._timer -= inFrameTime;
|
||||
if(this._timer <= 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(this._swipeMC != null)
|
||||
{
|
||||
if(Boolean(this._swipeMC.weaponDone))
|
||||
{
|
||||
this._timer = 2;
|
||||
}
|
||||
else if(Boolean(this._swipeMC.hitActive))
|
||||
{
|
||||
collisionPoint = this._swipeMC.getCollisionPoint();
|
||||
collisionPoint.x += x;
|
||||
collisionPoint.y += y;
|
||||
if(this._npc != null)
|
||||
{
|
||||
if(Boolean(this._players))
|
||||
{
|
||||
for(i = this._players.length - 1; i >= 0; i--)
|
||||
{
|
||||
avView = AvatarManager.avatarViewList[this._players[i]];
|
||||
if(avView != null)
|
||||
{
|
||||
hitX = collisionPoint.x - (avView.x + QuestManager.QUEST_PLAYER_AVATAR_OFFSETX);
|
||||
hitY = collisionPoint.y - (avView.y + QuestManager.QUEST_PLAYER_AVATAR_OFFSETY);
|
||||
if(hitX * hitX + hitY * hitY < (this._swipeMC.radius + QuestManager.QUEST_PLAYER_AVATAR_RADIUS) * (this._swipeMC.radius + QuestManager.QUEST_PLAYER_AVATAR_RADIUS))
|
||||
{
|
||||
this.handleHit(null,avView,this._localPlayerLaunched);
|
||||
this._players.splice(i,1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._players.splice(i,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
hitActors = QuestManager.meleeRadiusCheck(this._meleeID,collisionPoint,this._swipeMC.radius,true);
|
||||
if(hitActors != null)
|
||||
{
|
||||
for each(questActor in hitActors)
|
||||
{
|
||||
this.handleHit(questActor,null,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hitActors = QuestManager.meleeRadiusCheck(this._meleeID,collisionPoint,this._swipeMC.radius,false);
|
||||
if(hitActors != null)
|
||||
{
|
||||
for each(questActor in hitActors)
|
||||
{
|
||||
this.handleHit(questActor,null,this._localPlayerLaunched);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleHit(inQuestActor:QuestActor, playerAvView:AvatarWorldView, localHit:Boolean) : void
|
||||
{
|
||||
var actorOffset:Point = null;
|
||||
if(inQuestActor != null)
|
||||
{
|
||||
inQuestActor.handleHit(localHit,this._weaponItem.defId);
|
||||
actorOffset = inQuestActor.actorOffset;
|
||||
actorOffset.x += inQuestActor.x - x;
|
||||
actorOffset.y += inQuestActor.y - y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(playerAvView == AvatarManager.playerAvatarWorldView)
|
||||
{
|
||||
QuestManager.questActorAttacked("",this._weaponItem.defId,0,0,this._npc);
|
||||
}
|
||||
actorOffset = new Point(QuestManager.QUEST_PLAYER_AVATAR_OFFSETX,QuestManager.QUEST_PLAYER_AVATAR_OFFSETY);
|
||||
actorOffset.x += playerAvView.x - x;
|
||||
actorOffset.y += playerAvView.y - y;
|
||||
}
|
||||
var mediaHelper:MediaHelper = new MediaHelper();
|
||||
mediaHelper.init(this._weaponItem.attackMediaRefId,this.onEffectLoaded,actorOffset);
|
||||
}
|
||||
|
||||
public function swipe(inItemDefID:int, inColors:uint, inLayer:Sprite, inTargetX:int, inTargetY:int, inNPC:QuestActor, inAvatarView:AvatarView) : Boolean
|
||||
{
|
||||
var key:Object = null;
|
||||
var cp:Point = null;
|
||||
var toTargetX:Number = NaN;
|
||||
var toTargetY:Number = NaN;
|
||||
var distance:Number = NaN;
|
||||
var angle:Number = NaN;
|
||||
this._weaponItem = ItemXtCommManager.getItemDef(inItemDefID);
|
||||
this._color = inColors;
|
||||
if(inNPC == null)
|
||||
{
|
||||
if(inAvatarView != null)
|
||||
{
|
||||
this._localPlayerLaunched = inAvatarView.userId == AvatarManager.playerSfsUserId;
|
||||
if(this._localPlayerLaunched)
|
||||
{
|
||||
QuestXtCommManager.sendQuestSwipe(this._weaponItem.defId,inTargetX,inTargetY,"",inAvatarView.userId,inColors);
|
||||
}
|
||||
x = inAvatarView.x + QuestManager.QUEST_PLAYER_AVATAR_OFFSETX;
|
||||
y = inAvatarView.y + QuestManager.QUEST_PLAYER_AVATAR_OFFSETY;
|
||||
this._mediaHelperObj = new MediaHelper();
|
||||
this._mediaHelperObj.init(this._weaponItem.attackMediaRefId,this.onSwipeLoaded,this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._localPlayerLaunched = false;
|
||||
this._players = new Array();
|
||||
for(key in AvatarManager.avatarViewList)
|
||||
{
|
||||
this._players.push(key);
|
||||
}
|
||||
cp = inNPC.actorOffset;
|
||||
this._npc = inNPC;
|
||||
x = this._npc.x + cp.x;
|
||||
y = this._npc.y + cp.y;
|
||||
this._mediaHelperObj = new MediaHelper();
|
||||
this._mediaHelperObj.init(this._weaponItem.attackMediaRefId,this.onSwipeLoaded,this);
|
||||
}
|
||||
if(this._mediaHelperObj != null)
|
||||
{
|
||||
toTargetX = inTargetX - x;
|
||||
toTargetY = inTargetY - y;
|
||||
if(toTargetX == 0 && toTargetY == 0)
|
||||
{
|
||||
toTargetX = 1;
|
||||
}
|
||||
distance = Math.sqrt(toTargetX * toTargetX + toTargetY * toTargetY);
|
||||
toTargetX /= distance;
|
||||
toTargetY /= distance;
|
||||
angle = Math.asin(toTargetX);
|
||||
if(toTargetY > 0)
|
||||
{
|
||||
angle = -(Math.PI + angle);
|
||||
}
|
||||
this._angle = angle * 180 / Math.PI;
|
||||
inLayer.addChild(this);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function onEffectLoaded(img:MovieClip) : void
|
||||
{
|
||||
img.x = img.passback.x;
|
||||
img.y = img.passback.y;
|
||||
img.effect();
|
||||
addChild(img);
|
||||
img.mediaHelper.destroy();
|
||||
}
|
||||
|
||||
private function onSwipeLoaded(img:MovieClip) : void
|
||||
{
|
||||
var colorArray:Array = PaletteHelper.getRGBColors(this._color);
|
||||
var colors:Array = new Array(new Array(colorArray[0].r,colorArray[0].g,colorArray[0].b),new Array(colorArray[1].r,colorArray[1].g,colorArray[1].b),new Array(colorArray[2].r,colorArray[2].g,colorArray[2].b),new Array(colorArray[3].r,colorArray[3].g,colorArray[3].b));
|
||||
img.rgbColors = colors;
|
||||
img.setColors();
|
||||
addChild(img);
|
||||
img.strike(this._angle);
|
||||
this._swipeMC = img;
|
||||
img.mediaHelper.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,617 @@
|
||||
package quest
|
||||
{
|
||||
import avatar.AvatarInfo;
|
||||
import avatar.AvatarManager;
|
||||
import avatar.AvatarWorldView;
|
||||
import avatar.NPCView;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.filters.GlowFilter;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.text.TextField;
|
||||
import flash.text.TextFormat;
|
||||
import gskinner.motion.GTween;
|
||||
import gskinner.motion.easing.Linear;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class QuestPlayerData extends Sprite
|
||||
{
|
||||
|
||||
private var _levelUpHelperBottom:MediaHelper;
|
||||
|
||||
private var _levelUpHelperTop:MediaHelper;
|
||||
|
||||
private var _levelUpMCBottom:MovieClip;
|
||||
|
||||
private var _levelUpMCTop:MovieClip;
|
||||
|
||||
private var _levelUpLoaded:Boolean;
|
||||
|
||||
public var _avatarWorldView:AvatarWorldView;
|
||||
|
||||
private var _tintFrames:int;
|
||||
|
||||
private var _statusText:TextField;
|
||||
|
||||
private var _statusTextTween:GTween;
|
||||
|
||||
private var _healingTween:GTween;
|
||||
|
||||
private var _healingHeart:MovieClip;
|
||||
|
||||
private var _uID:int;
|
||||
|
||||
private var _itemEmoticonSound:SoundChannel;
|
||||
|
||||
private var _itemEmoticonSoundName:String;
|
||||
|
||||
private var _playerDamageMC:MovieClip;
|
||||
|
||||
private var _playerDamageMH:MediaHelper;
|
||||
|
||||
private var _pendingPlayerDamageMax:int;
|
||||
|
||||
private var _pendingPlayerDamageBefore:int;
|
||||
|
||||
private var _pendingPlayerDamageAfter:int;
|
||||
|
||||
private var _avSwitchedNPC:NPCView;
|
||||
|
||||
private var _avSwitchNPCID:int;
|
||||
|
||||
private var _dropOrbMC:MovieClip;
|
||||
|
||||
private var _dropOrbMH:MediaHelper;
|
||||
|
||||
public function QuestPlayerData()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
private function updateAvatarStatus() : void
|
||||
{
|
||||
if(this._avatarWorldView == null)
|
||||
{
|
||||
this._avatarWorldView = AvatarManager.avatarViewList[this._uID];
|
||||
if(Boolean(this._avatarWorldView))
|
||||
{
|
||||
this._avatarWorldView.addChild(this._statusText);
|
||||
this._avatarWorldView.addChild(this._healingHeart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function init(uID:int) : void
|
||||
{
|
||||
this._uID = uID;
|
||||
this._avSwitchedNPC = null;
|
||||
this._statusText = new TextField();
|
||||
this._statusText.multiline = false;
|
||||
this._statusText.selectable = false;
|
||||
this._statusText.embedFonts = true;
|
||||
this._statusText.defaultTextFormat = new TextFormat("TikiIsland-Regular",36,65280);
|
||||
this._statusText.filters = [new GlowFilter(0,1,3,3,10,2)];
|
||||
this._statusText.visible = false;
|
||||
this._healingHeart = GETDEFINITIONBYNAME("questHeartsCont");
|
||||
this._healingHeart.visible = false;
|
||||
this._pendingPlayerDamageMax = 0;
|
||||
this._playerDamageMH = new MediaHelper();
|
||||
this._playerDamageMH.init(2252,this.onPlayerDamageLoaded);
|
||||
this.updateAvatarStatus();
|
||||
}
|
||||
|
||||
private function playLevelUpEffect() : void
|
||||
{
|
||||
if(this._levelUpLoaded)
|
||||
{
|
||||
this._levelUpLoaded = false;
|
||||
if(Boolean(this._levelUpMCTop) && Boolean(this._levelUpMCBottom))
|
||||
{
|
||||
this._levelUpMCTop.gotoAndPlay("tintOn");
|
||||
this._levelUpMCTop.addEventListener(Event.ENTER_FRAME,this.levelUpEnterFrameHandler);
|
||||
this._levelUpMCBottom.gotoAndPlay("tintOn");
|
||||
this.updateAvatarStatus();
|
||||
if(Boolean(this._avatarWorldView))
|
||||
{
|
||||
this._avatarWorldView.setBlendColor(4290903190,7534606);
|
||||
}
|
||||
QuestManager.playSound("ajq_stingerLevelUp");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._levelUpLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function playerDamaged(inMaxHearts:int, inHeartsBeforeDamage:int, inHeartsAfterDamage:int) : void
|
||||
{
|
||||
if(this._playerDamageMC != null && this._avatarWorldView != null)
|
||||
{
|
||||
if(this._playerDamageMC.parent != QuestManager._layerManager.room_chat)
|
||||
{
|
||||
this._pendingPlayerDamageMax = 0;
|
||||
this._playerDamageMC.x = this._avatarWorldView.x;
|
||||
this._playerDamageMC.y = this._avatarWorldView.y;
|
||||
QuestManager._layerManager.room_chat.addChild(this._playerDamageMC);
|
||||
this._playerDamageMC.hit(inMaxHearts,inHeartsBeforeDamage,inHeartsAfterDamage);
|
||||
this._playerDamageMC.addEventListener(Event.ENTER_FRAME,this.playerDamageFrameHandler);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._pendingPlayerDamageMax = inMaxHearts;
|
||||
this._pendingPlayerDamageBefore = inHeartsBeforeDamage;
|
||||
this._pendingPlayerDamageAfter = inHeartsAfterDamage;
|
||||
}
|
||||
}
|
||||
|
||||
private function onPlayerDamageLoaded(img:MovieClip) : void
|
||||
{
|
||||
this._playerDamageMC = img;
|
||||
this._playerDamageMH.destroy();
|
||||
this._playerDamageMH = null;
|
||||
if(this._pendingPlayerDamageMax > 0)
|
||||
{
|
||||
this.playerDamaged(this._pendingPlayerDamageMax,this._pendingPlayerDamageBefore,this._pendingPlayerDamageAfter);
|
||||
}
|
||||
}
|
||||
|
||||
private function onLevelUpTopLoaded(img:MovieClip) : void
|
||||
{
|
||||
if(Boolean(img))
|
||||
{
|
||||
if(Boolean(this._levelUpMCTop) && Boolean(this._levelUpMCTop.parent))
|
||||
{
|
||||
this._levelUpMCTop.parent.removeChild(this._levelUpMCTop);
|
||||
}
|
||||
this._levelUpMCTop = img;
|
||||
this.updateAvatarStatus();
|
||||
if(Boolean(this._avatarWorldView))
|
||||
{
|
||||
this._levelUpMCTop.x = this._avatarWorldView.x;
|
||||
this._levelUpMCTop.y = this._avatarWorldView.y;
|
||||
QuestManager._layerManager.room_chat.addChild(this._levelUpMCTop);
|
||||
}
|
||||
this.playLevelUpEffect();
|
||||
}
|
||||
}
|
||||
|
||||
private function onLevelUpBottomLoaded(img:MovieClip) : void
|
||||
{
|
||||
if(Boolean(img))
|
||||
{
|
||||
if(Boolean(this._levelUpMCBottom) && Boolean(this._levelUpMCBottom.parent))
|
||||
{
|
||||
this._levelUpMCBottom.parent.removeChild(this._levelUpMCBottom);
|
||||
}
|
||||
this._levelUpMCBottom = img;
|
||||
this.updateAvatarStatus();
|
||||
if(Boolean(this._avatarWorldView))
|
||||
{
|
||||
this._avatarWorldView.addChildAt(this._levelUpMCBottom,0);
|
||||
}
|
||||
this.playLevelUpEffect();
|
||||
}
|
||||
}
|
||||
|
||||
private function playerDamageFrameHandler(e:Event) : void
|
||||
{
|
||||
if(Boolean(this._avatarWorldView))
|
||||
{
|
||||
this._playerDamageMC.x = this._avatarWorldView.x;
|
||||
this._playerDamageMC.y = this._avatarWorldView.y;
|
||||
if(this._playerDamageMC != null && Boolean(this._playerDamageMC.finished))
|
||||
{
|
||||
this._playerDamageMC.removeEventListener(Event.ENTER_FRAME,this.playerDamageFrameHandler);
|
||||
if(this._playerDamageMC.parent == QuestManager._layerManager.room_chat)
|
||||
{
|
||||
QuestManager._layerManager.room_chat.removeChild(this._playerDamageMC);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function levelUpEnterFrameHandler(e:Event) : void
|
||||
{
|
||||
if(this._levelUpMCTop != null)
|
||||
{
|
||||
this._levelUpMCTop.x = this._avatarWorldView.x;
|
||||
this._levelUpMCTop.y = this._avatarWorldView.y;
|
||||
}
|
||||
if(this._levelUpMCTop.currentFrameLabel == "tintOff")
|
||||
{
|
||||
this.updateAvatarStatus();
|
||||
if(Boolean(this._avatarWorldView))
|
||||
{
|
||||
this._avatarWorldView.setBlendColor(0);
|
||||
}
|
||||
}
|
||||
if(this._levelUpMCTop.currentFrameLabel == "finished")
|
||||
{
|
||||
this._levelUpMCTop.removeEventListener(Event.ENTER_FRAME,this.levelUpEnterFrameHandler);
|
||||
}
|
||||
}
|
||||
|
||||
private function onTweenComplete(gtween:GTween) : void
|
||||
{
|
||||
if(Boolean(this._avatarWorldView))
|
||||
{
|
||||
if(Boolean(this._healingHeart) && Boolean(this._healingHeart.parent) && this._healingHeart.parent == this._avatarWorldView)
|
||||
{
|
||||
this._avatarWorldView.removeChild(this._healingHeart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onTweenStatusTextComplete(gtween:GTween) : void
|
||||
{
|
||||
if(Boolean(this._avatarWorldView))
|
||||
{
|
||||
if(Boolean(this._statusText) && Boolean(this._statusText.parent) && this._statusText.parent == this._avatarWorldView)
|
||||
{
|
||||
this._avatarWorldView.removeChild(this._statusText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function levelUp(newLevel:int) : void
|
||||
{
|
||||
if(Boolean(this._avatarWorldView))
|
||||
{
|
||||
this._avatarWorldView.updateNameBarLevelShape(newLevel);
|
||||
}
|
||||
this._levelUpHelperTop = new MediaHelper();
|
||||
this._levelUpHelperTop.init(1823,this.onLevelUpTopLoaded);
|
||||
this._levelUpHelperBottom = new MediaHelper();
|
||||
this._levelUpHelperBottom.init(1875,this.onLevelUpBottomLoaded);
|
||||
}
|
||||
|
||||
public function handleHit(healthChange:int) : void
|
||||
{
|
||||
var ai:AvatarInfo = null;
|
||||
if(this._avatarWorldView != null)
|
||||
{
|
||||
ai = gMainFrame.userInfo.getAvatarInfoByUserName(this._avatarWorldView.userName);
|
||||
if(ai != null)
|
||||
{
|
||||
if(ai.questHealthPercentage > 0)
|
||||
{
|
||||
this._tintFrames = 13;
|
||||
this.playHitText(String(healthChange));
|
||||
if(Boolean(this._avatarWorldView))
|
||||
{
|
||||
this._avatarWorldView.handleOffScreenHit();
|
||||
addEventListener(Event.ENTER_FRAME,this.hitEnterFrameHandler);
|
||||
if(this._avatarWorldView == AvatarManager.playerAvatarWorldView)
|
||||
{
|
||||
QuestManager.playSound("ajq_playerhit");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(Boolean(this._avatarWorldView))
|
||||
{
|
||||
this._avatarWorldView.handleOffScreenSleep();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function playHitText(hitText:String) : void
|
||||
{
|
||||
this.updateAvatarStatus();
|
||||
if(Boolean(this._avatarWorldView))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function playStatusText(statusText:String) : void
|
||||
{
|
||||
this._statusText.visible = true;
|
||||
this._statusText.alpha = 2;
|
||||
this._statusText.text = statusText;
|
||||
this._statusText.x = this.x - this._statusText.textWidth * 0.5 - this._avatarWorldView.radius * 0.5;
|
||||
this._statusText.y = this.y - this._avatarWorldView.radius * 2;
|
||||
if(Boolean(this._statusTextTween))
|
||||
{
|
||||
this._statusTextTween.resetValues({
|
||||
"y":this._statusText.y - 90,
|
||||
"alpha":0
|
||||
});
|
||||
this._statusTextTween.beginning();
|
||||
this._statusTextTween.paused = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._statusTextTween = new GTween(this._statusText,1,{
|
||||
"y":this._statusText.y - 90,
|
||||
"alpha":0
|
||||
},{
|
||||
"onComplete":this.onTweenComplete,
|
||||
"ease":Linear.easeNone
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function handleHealing(healthChange:int) : void
|
||||
{
|
||||
this.updateAvatarStatus();
|
||||
if(Boolean(this._avatarWorldView))
|
||||
{
|
||||
this._healingHeart.visible = true;
|
||||
this._healingHeart.alpha = 2;
|
||||
this._healingHeart.x = this.x - this._avatarWorldView.radius * 0.5;
|
||||
this._healingHeart.y = this.y - this._avatarWorldView.radius * 2 - 35;
|
||||
if(Boolean(this._healingTween))
|
||||
{
|
||||
this._healingTween.resetValues({
|
||||
"y":this._healingHeart.y,
|
||||
"alpha":0
|
||||
});
|
||||
this._healingTween.beginning();
|
||||
this._healingTween.paused = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._healingTween = new GTween(this._healingHeart,1.5,{
|
||||
"y":this._healingHeart.y,
|
||||
"alpha":0
|
||||
},{
|
||||
"onComplete":this.onTweenComplete,
|
||||
"ease":Linear.easeNone
|
||||
});
|
||||
}
|
||||
this._avatarWorldView.handleOffScreenSleep(true);
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
this.stopItemEmoticonSound();
|
||||
if(hasEventListener(Event.ENTER_FRAME))
|
||||
{
|
||||
removeEventListener(Event.ENTER_FRAME,this.hitEnterFrameHandler);
|
||||
}
|
||||
if(Boolean(this._levelUpMCTop) && this._levelUpMCTop.hasEventListener(Event.ENTER_FRAME))
|
||||
{
|
||||
this._levelUpMCTop.removeEventListener(Event.ENTER_FRAME,this.levelUpEnterFrameHandler);
|
||||
}
|
||||
if(this._playerDamageMC != null)
|
||||
{
|
||||
this._playerDamageMC.removeEventListener(Event.ENTER_FRAME,this.playerDamageFrameHandler);
|
||||
}
|
||||
if(this._playerDamageMH != null)
|
||||
{
|
||||
this._playerDamageMH.destroy();
|
||||
this._playerDamageMH = null;
|
||||
}
|
||||
if(this._dropOrbMH != null)
|
||||
{
|
||||
this._dropOrbMH.destroy();
|
||||
this._dropOrbMH = null;
|
||||
}
|
||||
if(this._dropOrbMC != null)
|
||||
{
|
||||
if(this._dropOrbMC.parent != null)
|
||||
{
|
||||
this._dropOrbMC.parent.removeChild(this._dropOrbMC);
|
||||
}
|
||||
this._dropOrbMC = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function soundEnterFrameHandler(e:Event) : void
|
||||
{
|
||||
var volume:Number = NaN;
|
||||
var toTargetX:Number = NaN;
|
||||
var toTargetY:Number = NaN;
|
||||
var targetRadius:Number = NaN;
|
||||
var minRadiusSquared:Number = NaN;
|
||||
var maxRadiusSquared:Number = NaN;
|
||||
if(Boolean(this._avatarWorldView))
|
||||
{
|
||||
if(this._itemEmoticonSoundName != null)
|
||||
{
|
||||
volume = 1;
|
||||
if(this._avatarWorldView != AvatarManager.playerAvatarWorldView && Boolean(AvatarManager.playerAvatarWorldView))
|
||||
{
|
||||
toTargetX = AvatarManager.playerAvatarWorldView.x - this._avatarWorldView.x;
|
||||
toTargetY = AvatarManager.playerAvatarWorldView.y - this._avatarWorldView.y;
|
||||
targetRadius = toTargetX * toTargetX + toTargetY * toTargetY;
|
||||
minRadiusSquared = 5 * 5;
|
||||
maxRadiusSquared = 600 * 600;
|
||||
if(targetRadius > maxRadiusSquared)
|
||||
{
|
||||
volume = 0;
|
||||
}
|
||||
else if(targetRadius >= minRadiusSquared)
|
||||
{
|
||||
volume = 1 - (targetRadius - minRadiusSquared) / (maxRadiusSquared - minRadiusSquared);
|
||||
}
|
||||
}
|
||||
if(volume > 0)
|
||||
{
|
||||
if(this._itemEmoticonSound == null)
|
||||
{
|
||||
this._itemEmoticonSound = QuestManager.playLoopingSound(this._itemEmoticonSoundName);
|
||||
}
|
||||
QuestManager.setSoundLevel(this._itemEmoticonSound,volume,this._avatarWorldView);
|
||||
}
|
||||
else if(this._itemEmoticonSound != null)
|
||||
{
|
||||
this._itemEmoticonSound.stop();
|
||||
this._itemEmoticonSound = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function hitEnterFrameHandler(e:Event) : void
|
||||
{
|
||||
this.updateAvatarStatus();
|
||||
if(Boolean(this._avatarWorldView))
|
||||
{
|
||||
if(this._avatarWorldView.isValid())
|
||||
{
|
||||
--this._tintFrames;
|
||||
switch(this._tintFrames)
|
||||
{
|
||||
case 10:
|
||||
case 6:
|
||||
case 2:
|
||||
this._avatarWorldView.setBlendColor(0);
|
||||
break;
|
||||
case 12:
|
||||
case 8:
|
||||
case 4:
|
||||
this._avatarWorldView.setBlendColor(3439329279,0,true);
|
||||
break;
|
||||
case 0:
|
||||
removeEventListener(Event.ENTER_FRAME,this.hitEnterFrameHandler);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
removeEventListener(Event.ENTER_FRAME,this.hitEnterFrameHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function stopItemEmoticonSound() : void
|
||||
{
|
||||
if(this._itemEmoticonSound != null)
|
||||
{
|
||||
this._itemEmoticonSound.stop();
|
||||
this._itemEmoticonSound = null;
|
||||
}
|
||||
if(this._itemEmoticonSoundName != null)
|
||||
{
|
||||
removeEventListener(Event.ENTER_FRAME,this.soundEnterFrameHandler);
|
||||
this._itemEmoticonSoundName = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function playItemEmoticonSound(inSound:String) : void
|
||||
{
|
||||
this.stopItemEmoticonSound();
|
||||
var index:int = inSound.lastIndexOf(".wav");
|
||||
if(index > 0)
|
||||
{
|
||||
inSound = inSound.substring(0,index);
|
||||
}
|
||||
inSound = inSound.toLowerCase();
|
||||
this._itemEmoticonSoundName = inSound;
|
||||
addEventListener(Event.ENTER_FRAME,this.soundEnterFrameHandler);
|
||||
}
|
||||
|
||||
public function setAvatarSwitched(inNpcId:int) : void
|
||||
{
|
||||
this.updateAvatarStatus();
|
||||
if(this._avSwitchedNPC != null)
|
||||
{
|
||||
if(this._avSwitchedNPC.parent != null)
|
||||
{
|
||||
this._avSwitchedNPC.parent.removeChild(this._avSwitchedNPC);
|
||||
}
|
||||
this._avSwitchedNPC.destroy();
|
||||
this._avSwitchedNPC = null;
|
||||
}
|
||||
if(this._avatarWorldView != null)
|
||||
{
|
||||
this._avatarWorldView.showAvatar();
|
||||
}
|
||||
this._avSwitchNPCID = inNpcId;
|
||||
}
|
||||
|
||||
public function onNpcLoaded() : void
|
||||
{
|
||||
if(this._avatarWorldView != null)
|
||||
{
|
||||
if(this._avSwitchedNPC != null)
|
||||
{
|
||||
this._avSwitchedNPC.x = this._avatarWorldView.x;
|
||||
this._avSwitchedNPC.y = this._avatarWorldView.y;
|
||||
this._avSwitchedNPC.npcMC.setVision(0);
|
||||
this._avSwitchedNPC.setNpcState(NPCView.NPC_STATE_IDLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function playerLeftRoom() : void
|
||||
{
|
||||
if(this._avSwitchedNPC != null)
|
||||
{
|
||||
if(this._avSwitchedNPC.parent != null)
|
||||
{
|
||||
this._avSwitchedNPC.parent.removeChild(this._avSwitchedNPC);
|
||||
}
|
||||
this._avSwitchedNPC.destroy();
|
||||
this._avSwitchedNPC = null;
|
||||
}
|
||||
this._avatarWorldView = null;
|
||||
}
|
||||
|
||||
public function heartbeat() : void
|
||||
{
|
||||
if(this._avatarWorldView != null)
|
||||
{
|
||||
if(this._avSwitchedNPC != null)
|
||||
{
|
||||
if(this._avSwitchedNPC.x != this._avatarWorldView.x || this._avSwitchedNPC.y != this._avatarWorldView.y)
|
||||
{
|
||||
this._avSwitchedNPC.setNpcState(NPCView.NPC_STATE_MOVE,this._avSwitchedNPC.x < this._avatarWorldView.x ? 90 : 270);
|
||||
this._avSwitchedNPC.x = this._avatarWorldView.x;
|
||||
this._avSwitchedNPC.y = this._avatarWorldView.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._avSwitchedNPC.setNpcState(NPCView.NPC_STATE_IDLE);
|
||||
}
|
||||
}
|
||||
else if(this._avSwitchNPCID != 0)
|
||||
{
|
||||
if(this._avatarWorldView.isValid())
|
||||
{
|
||||
this._avatarWorldView.hideAvatar();
|
||||
this._avSwitchedNPC = new NPCView();
|
||||
this._avSwitchedNPC.x = this._avatarWorldView.x;
|
||||
this._avSwitchedNPC.y = this._avatarWorldView.y;
|
||||
this._avSwitchedNPC.init(this._avSwitchNPCID,0,-1,false,this.onNpcLoaded);
|
||||
QuestManager._layerManager.room_avatars.addChild(this._avSwitchedNPC);
|
||||
}
|
||||
}
|
||||
if(this._dropOrbMC != null)
|
||||
{
|
||||
if(Boolean(this._dropOrbMC.removeMe))
|
||||
{
|
||||
this._dropOrbMC.parent.removeChild(this._dropOrbMC);
|
||||
this._dropOrbMC = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onDropOrbLoaded(img:MovieClip) : void
|
||||
{
|
||||
this._dropOrbMC = img;
|
||||
this._dropOrbMC.x = this._avatarWorldView.x;
|
||||
this._dropOrbMC.y = this._avatarWorldView.y;
|
||||
QuestManager._layerManager.room_chat.addChild(this._dropOrbMC);
|
||||
}
|
||||
|
||||
public function dropOrb() : void
|
||||
{
|
||||
if(this._avatarWorldView != null)
|
||||
{
|
||||
if(this._dropOrbMH != null)
|
||||
{
|
||||
this._dropOrbMH.destroy();
|
||||
}
|
||||
this._dropOrbMH = new MediaHelper();
|
||||
this._dropOrbMH.init(3588,this.onDropOrbLoaded);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,345 @@
|
||||
package quest
|
||||
{
|
||||
import avatar.AvatarManager;
|
||||
import avatar.AvatarView;
|
||||
import avatar.AvatarWorldView;
|
||||
import com.sbi.graphics.PaletteHelper;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.geom.Point;
|
||||
import item.ItemXtCommManager;
|
||||
import loader.MediaHelper;
|
||||
import room.RoomManagerWorld;
|
||||
|
||||
public class QuestProjectile extends Sprite
|
||||
{
|
||||
|
||||
private static const PROJECTILE_VELOCITY:int = 400;
|
||||
|
||||
private static const PROJECTILE_RANGE:int = 600;
|
||||
|
||||
private static const PROJECTILE_RADIUS:int = 10;
|
||||
|
||||
private var _weaponItem:Object;
|
||||
|
||||
private var _npc:QuestActor;
|
||||
|
||||
private var _mediaHelperObj:MediaHelper;
|
||||
|
||||
private var _strikeMC:MovieClip;
|
||||
|
||||
private var _projectileMC:MovieClip;
|
||||
|
||||
private var _aimX:Number;
|
||||
|
||||
private var _aimY:Number;
|
||||
|
||||
private var _distanceTravelled:Number;
|
||||
|
||||
private var _timer:Number;
|
||||
|
||||
private var _angle:Number;
|
||||
|
||||
private var _collisionOffset:Point;
|
||||
|
||||
private var _color:uint;
|
||||
|
||||
private var _localPlayerLaunched:Boolean;
|
||||
|
||||
private var _healProjectile:Boolean;
|
||||
|
||||
public function QuestProjectile()
|
||||
{
|
||||
super();
|
||||
this._distanceTravelled = 0;
|
||||
this._timer = 0;
|
||||
}
|
||||
|
||||
public function get angle() : Number
|
||||
{
|
||||
return this._angle;
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
if(this._strikeMC != null && this._strikeMC.parent != null)
|
||||
{
|
||||
this._strikeMC.parent.removeChild(this._strikeMC);
|
||||
}
|
||||
if(this._mediaHelperObj != null)
|
||||
{
|
||||
this._mediaHelperObj.destroy();
|
||||
this._mediaHelperObj = null;
|
||||
}
|
||||
if(parent != null)
|
||||
{
|
||||
parent.removeChild(this);
|
||||
}
|
||||
this._strikeMC.weapon.rotation = 0;
|
||||
QuestManager.recycle(this._weaponItem.attackMediaRefId,this);
|
||||
}
|
||||
|
||||
public function heartbeat(inFrameTime:Number) : Boolean
|
||||
{
|
||||
var hitActor:QuestActor = null;
|
||||
var key:Object = null;
|
||||
var avView:AvatarWorldView = null;
|
||||
var hitX:Number = NaN;
|
||||
var hitY:Number = NaN;
|
||||
if(this._timer == 0)
|
||||
{
|
||||
if(this._projectileMC != null)
|
||||
{
|
||||
x += this._aimX * PROJECTILE_VELOCITY * inFrameTime;
|
||||
y += this._aimY * PROJECTILE_VELOCITY * inFrameTime;
|
||||
this._distanceTravelled += PROJECTILE_VELOCITY * inFrameTime;
|
||||
if(this._distanceTravelled > PROJECTILE_RANGE || RoomManagerWorld.instance.collisionTestGrid(x + this._collisionOffset.x,y + this._collisionOffset.y) == 1)
|
||||
{
|
||||
this.handleHit(true,null,null,false);
|
||||
}
|
||||
else if(this._npc != null || this._healProjectile)
|
||||
{
|
||||
for(key in AvatarManager.avatarViewList)
|
||||
{
|
||||
avView = AvatarManager.avatarViewList[key];
|
||||
if(avView != null)
|
||||
{
|
||||
hitX = x + this._collisionOffset.x - (avView.x + QuestManager.QUEST_PLAYER_AVATAR_OFFSETX);
|
||||
hitY = y + this._collisionOffset.y - (avView.y + QuestManager.QUEST_PLAYER_AVATAR_OFFSETY);
|
||||
if(hitX * hitX + hitY * hitY < (PROJECTILE_RADIUS + QuestManager.QUEST_PLAYER_AVATAR_RADIUS) * (PROJECTILE_RADIUS + QuestManager.QUEST_PLAYER_AVATAR_RADIUS))
|
||||
{
|
||||
this.handleHit(false,null,avView,this._localPlayerLaunched);
|
||||
}
|
||||
}
|
||||
}
|
||||
hitActor = QuestManager.projectileRadiusCheck(x + this._collisionOffset.x,y + this._collisionOffset.y,PROJECTILE_RADIUS,true);
|
||||
if(hitActor != null)
|
||||
{
|
||||
this.handleHit(false,hitActor,null,true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hitActor = QuestManager.projectileRadiusCheck(x + this._collisionOffset.x,y + this._collisionOffset.y,PROJECTILE_RADIUS,false);
|
||||
if(hitActor != null)
|
||||
{
|
||||
this.handleHit(false,hitActor,null,this._localPlayerLaunched);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._timer -= inFrameTime;
|
||||
if(this._timer <= 0)
|
||||
{
|
||||
this._timer = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleHit(inHitCollision:Boolean, inQuestActor:QuestActor, playerAvView:AvatarWorldView, localHit:Boolean) : void
|
||||
{
|
||||
var actorOffset:Point = null;
|
||||
this._projectileMC.visible = false;
|
||||
this._timer = 2;
|
||||
if(inHitCollision == false)
|
||||
{
|
||||
if(inQuestActor != null)
|
||||
{
|
||||
inQuestActor.handleHit(localHit,this._weaponItem.defId);
|
||||
actorOffset = inQuestActor.actorOffset;
|
||||
x = inQuestActor.x + actorOffset.x;
|
||||
y = inQuestActor.y + actorOffset.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!this._healProjectile)
|
||||
{
|
||||
if(playerAvView == AvatarManager.playerAvatarWorldView)
|
||||
{
|
||||
QuestManager.questActorAttacked("",this._weaponItem.defId,0,0,this._npc);
|
||||
}
|
||||
}
|
||||
else if(this._localPlayerLaunched)
|
||||
{
|
||||
QuestXtCommManager.questPlayerHeal(this._weaponItem.defId,playerAvView.avatarData.sfsUserId);
|
||||
}
|
||||
actorOffset = new Point(QuestManager.QUEST_PLAYER_AVATAR_OFFSETX,QuestManager.QUEST_PLAYER_AVATAR_OFFSETY);
|
||||
x = actorOffset.x + playerAvView.x;
|
||||
y = actorOffset.y + playerAvView.y;
|
||||
}
|
||||
this._mediaHelperObj = new MediaHelper();
|
||||
this._mediaHelperObj.init(this._weaponItem.attackMediaRefId,this.onEffectLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
private function setAngle() : void
|
||||
{
|
||||
var toTargetX:Number = this._aimX - x;
|
||||
var toTargetY:Number = this._aimY - y;
|
||||
if(toTargetX == 0 && toTargetY == 0)
|
||||
{
|
||||
toTargetX = 1;
|
||||
}
|
||||
var distance:Number = Math.sqrt(toTargetX * toTargetX + toTargetY * toTargetY);
|
||||
this._aimX = toTargetX / distance;
|
||||
this._aimY = toTargetY / distance;
|
||||
var angle:Number = Math.asin(this._aimX);
|
||||
if(this._aimY > 0)
|
||||
{
|
||||
angle = -(Math.PI + angle);
|
||||
}
|
||||
this._angle = angle * 180 / Math.PI;
|
||||
}
|
||||
|
||||
public function relaunch(inItemDefID:int, inColor:uint, inLayer:Sprite, inTargetX:int, inTargetY:int, inNPC:QuestActor, inAvatarView:AvatarView) : Boolean
|
||||
{
|
||||
var cp:Point = null;
|
||||
this._color = inColor;
|
||||
this._aimX = inTargetX;
|
||||
this._aimY = inTargetY;
|
||||
this._healProjectile = false;
|
||||
this._distanceTravelled = 0;
|
||||
this._timer = 0;
|
||||
if(inNPC == null)
|
||||
{
|
||||
if(Boolean(inAvatarView))
|
||||
{
|
||||
this._localPlayerLaunched = inAvatarView.userId == AvatarManager.playerSfsUserId;
|
||||
if(this._localPlayerLaunched)
|
||||
{
|
||||
QuestXtCommManager.sendQuestProjectileLaunch(this._weaponItem.defId,inTargetX,inTargetY,"",inAvatarView.userId,inColor);
|
||||
}
|
||||
this._healProjectile = this._weaponItem.attack < 0;
|
||||
x = this._strikeMC.x = inAvatarView.x + QuestManager.QUEST_PLAYER_AVATAR_OFFSETX;
|
||||
y = this._strikeMC.y = inAvatarView.y + QuestManager.QUEST_PLAYER_AVATAR_OFFSETY;
|
||||
this.setAngle();
|
||||
this._strikeMC.strike(this._angle);
|
||||
inLayer.addChild(this._strikeMC);
|
||||
this._projectileMC.visible = true;
|
||||
this._projectileMC.projectile(this._angle);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._localPlayerLaunched = false;
|
||||
cp = inNPC.actorOffset;
|
||||
this._npc = inNPC;
|
||||
x = this._strikeMC.x = this._npc.x + cp.x;
|
||||
y = this._strikeMC.x = this._npc.y + cp.y;
|
||||
this.setAngle();
|
||||
this._strikeMC.strike(this._angle);
|
||||
inLayer.addChild(this._strikeMC);
|
||||
this._projectileMC.visible = true;
|
||||
this._projectileMC.projectile(this._angle);
|
||||
}
|
||||
inLayer.addChild(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function launch(inItemDefID:int, inColor:uint, inLayer:Sprite, inTargetX:int, inTargetY:int, inNPC:QuestActor, inAvatarView:AvatarView) : Boolean
|
||||
{
|
||||
var weaponItem:Object = null;
|
||||
var cp:Point = null;
|
||||
this._color = inColor;
|
||||
this._weaponItem = ItemXtCommManager.getItemDef(inItemDefID);
|
||||
this._aimX = inTargetX;
|
||||
this._aimY = inTargetY;
|
||||
this._healProjectile = false;
|
||||
if(inNPC == null)
|
||||
{
|
||||
if(Boolean(inAvatarView))
|
||||
{
|
||||
this._localPlayerLaunched = inAvatarView.userId == AvatarManager.playerSfsUserId;
|
||||
if(this._localPlayerLaunched)
|
||||
{
|
||||
QuestXtCommManager.sendQuestProjectileLaunch(this._weaponItem.defId,inTargetX,inTargetY,"",inAvatarView.userId,inColor);
|
||||
}
|
||||
weaponItem = ItemXtCommManager.getItemDef(inItemDefID);
|
||||
if(Boolean(weaponItem))
|
||||
{
|
||||
this._healProjectile = weaponItem.attack < 0;
|
||||
}
|
||||
x = inAvatarView.x + QuestManager.QUEST_PLAYER_AVATAR_OFFSETX;
|
||||
y = inAvatarView.y + QuestManager.QUEST_PLAYER_AVATAR_OFFSETY;
|
||||
this._mediaHelperObj = new MediaHelper();
|
||||
this._mediaHelperObj.init(this._weaponItem.attackMediaRefId,this.onStrikeLoaded);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._localPlayerLaunched = false;
|
||||
cp = inNPC.actorOffset;
|
||||
this._npc = inNPC;
|
||||
x = this._npc.x + cp.x;
|
||||
y = this._npc.y + cp.y;
|
||||
this._mediaHelperObj = new MediaHelper();
|
||||
this._mediaHelperObj.init(this._weaponItem.attackMediaRefId,this.onStrikeLoaded);
|
||||
}
|
||||
if(this._mediaHelperObj != null)
|
||||
{
|
||||
this.setAngle();
|
||||
inLayer.addChild(this);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function onStrikeLoaded(img:MovieClip) : void
|
||||
{
|
||||
var colorArray:Array = null;
|
||||
var colors:Array = null;
|
||||
if(parent != null)
|
||||
{
|
||||
colorArray = PaletteHelper.getRGBColors(this._color);
|
||||
colors = new Array(new Array(colorArray[0].r,colorArray[0].g,colorArray[0].b),new Array(colorArray[1].r,colorArray[1].g,colorArray[1].b),new Array(colorArray[2].r,colorArray[2].g,colorArray[2].b),new Array(colorArray[3].r,colorArray[3].g,colorArray[3].b));
|
||||
img.rgbColors = colors;
|
||||
img.setColors();
|
||||
img.x += x;
|
||||
img.y += y;
|
||||
img.strike(this._angle);
|
||||
parent.addChild(img);
|
||||
this._strikeMC = img;
|
||||
if(this._mediaHelperObj != null)
|
||||
{
|
||||
this._mediaHelperObj.destroy();
|
||||
this._mediaHelperObj = null;
|
||||
}
|
||||
this._mediaHelperObj = new MediaHelper();
|
||||
this._mediaHelperObj.init(this._weaponItem.attackMediaRefId,this.onProjectileLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
private function onEffectLoaded(img:MovieClip) : void
|
||||
{
|
||||
addChild(img);
|
||||
img.effect();
|
||||
if(this._mediaHelperObj != null)
|
||||
{
|
||||
this._mediaHelperObj.destroy();
|
||||
this._mediaHelperObj = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function onProjectileLoaded(img:MovieClip) : void
|
||||
{
|
||||
var colorArray:Array = PaletteHelper.getRGBColors(this._color);
|
||||
var colors:Array = new Array(new Array(colorArray[0].r,colorArray[0].g,colorArray[0].b),new Array(colorArray[1].r,colorArray[1].g,colorArray[1].b),new Array(colorArray[2].r,colorArray[2].g,colorArray[2].b),new Array(colorArray[3].r,colorArray[3].g,colorArray[3].b));
|
||||
img.rgbColors = colors;
|
||||
img.setColors();
|
||||
this._projectileMC = img;
|
||||
addChild(this._projectileMC);
|
||||
this._projectileMC.projectile(this._angle);
|
||||
this._collisionOffset = this._projectileMC.getCollisionPoint();
|
||||
if(this._mediaHelperObj != null)
|
||||
{
|
||||
this._mediaHelperObj.destroy();
|
||||
this._mediaHelperObj = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,841 @@
|
||||
package quest
|
||||
{
|
||||
import avatar.AvatarManager;
|
||||
import com.carlcalderon.arthropod.Debug;
|
||||
import com.sbi.client.SFEvent;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import den.DenXtCommManager;
|
||||
import flash.utils.Dictionary;
|
||||
import gui.AdventureJoin;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import loader.DefPacksDefHelper;
|
||||
import localization.LocalizationManager;
|
||||
import room.RoomManagerWorld;
|
||||
import room.RoomXtCommManager;
|
||||
|
||||
public class QuestXtCommManager
|
||||
{
|
||||
|
||||
private static var _questCache:Array;
|
||||
|
||||
private static var _questDefLookups:Array;
|
||||
|
||||
private static var _scriptDefs:Object;
|
||||
|
||||
private static var _wasRoomWeCameFromDen:Boolean;
|
||||
|
||||
private static var _autoStartQuestOnNextWaitResponse:Boolean;
|
||||
|
||||
public function QuestXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
_questCache = new Array();
|
||||
_questDefLookups = new Array();
|
||||
_autoStartQuestOnNextWaitResponse = false;
|
||||
}
|
||||
|
||||
public static function questAskComplete(actorName:String, actorState:int, askResult:int) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qaskr",[actorName,actorState,askResult]);
|
||||
}
|
||||
|
||||
public static function questMiniGameComplete(actorName:String, actorState:int, gameResult:int) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qmgc",[actorName,actorState,gameResult]);
|
||||
}
|
||||
|
||||
public static function questActorAttacked(actorId:String, defId:int, inX:int, inY:int) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qaa",[actorId,actorId == "" ? 1 : 0,defId,inX,inY]);
|
||||
}
|
||||
|
||||
public static function questPhantomAttackDestructible(attackerId:String, actorId:String) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qpad",[attackerId,actorId]);
|
||||
}
|
||||
|
||||
public static function questPlayerHeal(defId:int, playerToHeal:int) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qph",[defId,playerToHeal]);
|
||||
}
|
||||
|
||||
public static function questActorTriggered(actorId:String, status:int = 0) : void
|
||||
{
|
||||
DebugUtility.debugTrace("sending \'qat\' command with actorId: " + actorId,Debug.RED);
|
||||
gMainFrame.server.setXtObject_Str("qat",[actorId,status]);
|
||||
}
|
||||
|
||||
public static function questPickUpItem(actorId:String) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qpup",[actorId,AvatarManager.playerSfsUserId]);
|
||||
}
|
||||
|
||||
public static function questActorTreasureTriggered(actorId:String, status:int = 0) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qatt",[actorId,status]);
|
||||
}
|
||||
|
||||
public static function questActorUntriggered(actorId:String) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qaut",[actorId]);
|
||||
}
|
||||
|
||||
public static function questActorPositionUpdate(actorId:String, inX:int, inY:int, velocity:int, seekType:int, inTargetX:int, inTargetY:int) : void
|
||||
{
|
||||
var isLocal:Boolean = actorId.substring(0,3) == "_l_";
|
||||
if(!isLocal && QuestManager.livePlayerCount() > 1)
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qau",[actorId,inX,inY,velocity,seekType,inTargetX,inTargetY]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function questActorSeek(actorId:String, requestSeek:int) : void
|
||||
{
|
||||
var data:Array = null;
|
||||
var isLocal:Boolean = actorId.substring(0,3) == "_l_";
|
||||
if(!isLocal)
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qas",[actorId,requestSeek]);
|
||||
}
|
||||
else
|
||||
{
|
||||
data = new Array();
|
||||
data[0] = 0;
|
||||
data[1] = 0;
|
||||
data[2] = actorId;
|
||||
data[3] = requestSeek;
|
||||
data[4] = AvatarManager.playerSfsUserId;
|
||||
QuestManager.handleQuestActorRequestSeekResponse(data);
|
||||
}
|
||||
}
|
||||
|
||||
public static function questBeamZap(actorId:String, inPlayerSfsId:int) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qbzap",[actorId,inPlayerSfsId]);
|
||||
}
|
||||
|
||||
public static function questPhantomZap(actorId:String, inPlayerSfsId:int, inX:int, inY:int) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qpzap",[actorId,inPlayerSfsId,inX,inY]);
|
||||
}
|
||||
|
||||
public static function questDropOrb(actorId:String, inPlayerSfsId:int, inAmount:int) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qdroporb",[actorId,inPlayerSfsId,inAmount]);
|
||||
}
|
||||
|
||||
public static function questFullRoomMinigameComplete(roomName:String, inGameResult:int) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qfrmgdone",[roomName,inGameResult]);
|
||||
}
|
||||
|
||||
public static function sendQuestJoinPrivate(questCreatorName:String) : void
|
||||
{
|
||||
if(Boolean(gMainFrame.server.getCurrentRoom()))
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
if(RoomXtCommManager._loadingNewRoom)
|
||||
{
|
||||
DebugUtility.debugTrace("IGNORING sendQuestWaitRequest request because user is already joining a new room!");
|
||||
return;
|
||||
}
|
||||
AvatarManager.joiningNewRoom = true;
|
||||
RoomXtCommManager._loadingNewRoom = true;
|
||||
RoomManagerWorld.instance.forceStopMovement();
|
||||
gMainFrame.server.setXtObject_Str("qjp",[gMainFrame.server.getCurrentRoomName(),questCreatorName]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendQuestJoinBuddy(buddyName:String) : void
|
||||
{
|
||||
var currRoomName:String = null;
|
||||
if(Boolean(gMainFrame.server.getCurrentRoom()))
|
||||
{
|
||||
if(RoomXtCommManager._loadingNewRoom)
|
||||
{
|
||||
DebugUtility.debugTrace("IGNORING sendQuestWaitRequest request because user is already joining a new room!");
|
||||
return;
|
||||
}
|
||||
AvatarManager.joiningNewRoom = true;
|
||||
RoomXtCommManager._loadingNewRoom = true;
|
||||
currRoomName = gMainFrame.server.getCurrentRoomName();
|
||||
if(currRoomName.indexOf("den") != -1)
|
||||
{
|
||||
_wasRoomWeCameFromDen = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_wasRoomWeCameFromDen = false;
|
||||
}
|
||||
RoomManagerWorld.instance.forceStopMovement();
|
||||
gMainFrame.server.setXtObject_Str("qjf",[gMainFrame.server.getCurrentRoomName(),buddyName]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendQuestCreateJoinPublic(questDefId:int, questDifficultyLevel:int = 0, autoStart:Boolean = false) : void
|
||||
{
|
||||
var currRoomName:String = null;
|
||||
if(Boolean(gMainFrame.server.getCurrentRoom()))
|
||||
{
|
||||
if(RoomXtCommManager._loadingNewRoom)
|
||||
{
|
||||
DebugUtility.debugTrace("IGNORING sendQuestWaitRequest request because user is already joining a new room!");
|
||||
return;
|
||||
}
|
||||
AvatarManager.joiningNewRoom = true;
|
||||
RoomXtCommManager._loadingNewRoom = true;
|
||||
currRoomName = gMainFrame.server.getCurrentRoomName();
|
||||
if(currRoomName.indexOf("den") != -1)
|
||||
{
|
||||
_wasRoomWeCameFromDen = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_wasRoomWeCameFromDen = false;
|
||||
}
|
||||
if(autoStart)
|
||||
{
|
||||
_autoStartQuestOnNextWaitResponse = true;
|
||||
}
|
||||
RoomManagerWorld.instance.forceStopMovement();
|
||||
gMainFrame.server.setXtObject_Str("qj",[gMainFrame.server.getCurrentRoomName(),questDefId,questDifficultyLevel,0]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendQuestCreateJoinPublicNoCurrentRoom(questDefId:int, questDifficultyLevel:int = 0) : void
|
||||
{
|
||||
if(RoomXtCommManager._loadingNewRoom)
|
||||
{
|
||||
DebugUtility.debugTrace("IGNORING sendQuestWaitRequest request because user is already joining a new room!");
|
||||
return;
|
||||
}
|
||||
AvatarManager.joiningNewRoom = true;
|
||||
RoomXtCommManager._loadingNewRoom = true;
|
||||
RoomManagerWorld.instance.forceStopMovement();
|
||||
gMainFrame.server.setXtObject_Str("qj",["",questDefId,questDifficultyLevel,0]);
|
||||
}
|
||||
|
||||
public static function sendQuestCreatePrivate(questDefId:int, questDifficultyLevel:int = 0, autoStart:Boolean = false) : void
|
||||
{
|
||||
if(Boolean(gMainFrame.server.getCurrentRoom()))
|
||||
{
|
||||
if(RoomXtCommManager._loadingNewRoom)
|
||||
{
|
||||
DebugUtility.debugTrace("IGNORING sendQuestWaitRequest request because user is already joining a new room!");
|
||||
return;
|
||||
}
|
||||
AvatarManager.joiningNewRoom = true;
|
||||
RoomXtCommManager._loadingNewRoom = true;
|
||||
if(autoStart)
|
||||
{
|
||||
_autoStartQuestOnNextWaitResponse = true;
|
||||
}
|
||||
RoomManagerWorld.instance.forceStopMovement();
|
||||
gMainFrame.server.setXtObject_Str("qjc",[gMainFrame.server.getCurrentRoomName(),questDefId,questDifficultyLevel]);
|
||||
GuiManager.grayOutHudItemsForPrivateLobby(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendQuestPrivateKick(playerToKick:String) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qjk",[playerToKick]);
|
||||
}
|
||||
|
||||
public static function sendQuestJoinCancel() : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qjx",[]);
|
||||
GuiManager.setSwapBtnGray(false);
|
||||
}
|
||||
|
||||
public static function sendQuestStartRequest() : void
|
||||
{
|
||||
if(Boolean(gMainFrame.server.getCurrentRoom()))
|
||||
{
|
||||
if(RoomXtCommManager._loadingNewRoom)
|
||||
{
|
||||
DebugUtility.debugTrace("IGNORING sendQuestStartRequest request because user is already joining a new room!");
|
||||
return;
|
||||
}
|
||||
AvatarManager.joiningNewRoom = true;
|
||||
RoomXtCommManager._loadingNewRoom = true;
|
||||
AvatarManager.resetCustomAdventureState();
|
||||
gMainFrame.server.setXtObject_Str("qs",[gMainFrame.server.getCurrentRoomName()]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendQuestProjectileLaunch(inMediaID:int, inX:int, inY:int, inActorID:String, inAvSfsID:int, inColor:uint) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qp",[inMediaID,inX,inY,inActorID,inAvSfsID,inColor]);
|
||||
}
|
||||
|
||||
public static function sendQuestSwipe(inMediaID:int, inX:int, inY:int, inActorID:String, inAvSfsID:int, inColors:uint) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qm",[inMediaID,inX,inY,inActorID,inAvSfsID,inColors]);
|
||||
}
|
||||
|
||||
public static function sendQuestExit(exitType:String) : void
|
||||
{
|
||||
DenXtCommManager.denChangePending = _wasRoomWeCameFromDen;
|
||||
gMainFrame.server.setXtObject_Str("qx",[exitType]);
|
||||
}
|
||||
|
||||
public static function sendAttackPlayer(inActorId:String, inPlayerSfsId:int, inWeaponItemDefId:int, inWeaponColor:uint) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qap",[inActorId,inPlayerSfsId,inWeaponItemDefId,inWeaponColor]);
|
||||
}
|
||||
|
||||
public static function sendQuestPlayerRequestRespawn(numGems:int, inX:int, inY:int) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qprr",[numGems,inX,inY]);
|
||||
}
|
||||
|
||||
public static function sendPlantSeed(inSeedDef:int, inX:int, inY:int) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qps",[inSeedDef,inX,inY]);
|
||||
}
|
||||
|
||||
public static function sendEatPhantom(inPlant:String, inPhantom:String, inX:int, inY:int) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qep",[inPlant,inPhantom,inX,inY]);
|
||||
}
|
||||
|
||||
public static function sendPlantAte(inPlant:String, inPhantom:String) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qpa",[inPlant,inPhantom]);
|
||||
}
|
||||
|
||||
public static function sendPickGiftResult(pickedGift:int, consolationPrize:Boolean) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qpgift",[pickedGift,consolationPrize ? "1" : "0"]);
|
||||
}
|
||||
|
||||
public static function sendQuestCloneQuest() : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qcq",[]);
|
||||
}
|
||||
|
||||
public static function sendQuestDropItem(inX:int, inY:int, pickup:String) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qdroppup",[inX,inY,pickup,AvatarManager.playerSfsUserId]);
|
||||
}
|
||||
|
||||
public static function sendQuestMovedItemsRequest() : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qmi",[]);
|
||||
}
|
||||
|
||||
public static function sendPlaySwfComplete() : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("qplayswf",[]);
|
||||
}
|
||||
|
||||
public static function handleXtReply(evt:SFEvent) : void
|
||||
{
|
||||
var data:Object = evt.obj;
|
||||
switch(data[0])
|
||||
{
|
||||
case "qap":
|
||||
QuestManager.handleAttackPlayer(data);
|
||||
break;
|
||||
case "qau":
|
||||
QuestManager.handleQuestActorPositionUpdateResponse(data);
|
||||
break;
|
||||
case "qahs":
|
||||
QuestManager.handleActorHealthStatus(data);
|
||||
break;
|
||||
case "qas":
|
||||
QuestManager.handleQuestActorRequestSeekResponse(data);
|
||||
break;
|
||||
case "qjp":
|
||||
AvatarManager.joiningNewRoom = false;
|
||||
RoomXtCommManager._loadingNewRoom = false;
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(data[2] != 0)
|
||||
{
|
||||
GuiManager.setSwapBtnGray(true);
|
||||
QuestManager.handleQuestJoinResponse(data,AdventureJoin.CUSTOM_WAITING_TYPE,data[5]);
|
||||
}
|
||||
else if(data[3] == "NV")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14816));
|
||||
}
|
||||
else if(data[3] == "FULL")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14817));
|
||||
}
|
||||
else if(data[3] == "NLAND")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(15706));
|
||||
}
|
||||
else if(data[3] == "NOCEAN")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(18476));
|
||||
}
|
||||
else if(data[3] == "NAIR")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(18475));
|
||||
}
|
||||
else if(data[3] == "NM")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14818));
|
||||
}
|
||||
else if(data[3] == "NB")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14819));
|
||||
}
|
||||
else if(data[3] == "NL")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdAndInsertOnly(14697,data[4]));
|
||||
}
|
||||
else if(data[3] == "NAIL")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14820));
|
||||
}
|
||||
else if(data[3] == "NDL")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdAndInsertOnly(14696,data[4]));
|
||||
}
|
||||
else if(data[3] == "NQ")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14822));
|
||||
}
|
||||
else if(data[3] == "NP")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(19656));
|
||||
}
|
||||
else
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14816));
|
||||
}
|
||||
break;
|
||||
case "qjc":
|
||||
AvatarManager.joiningNewRoom = false;
|
||||
RoomXtCommManager._loadingNewRoom = false;
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(data[2] != 0)
|
||||
{
|
||||
GuiManager.closeWorldMapIfOpen();
|
||||
QuestManager.handleQuestJoinResponse(data,AdventureJoin.CUSTOM_SETTINGS_TYPE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(data[3] == "NV")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14816));
|
||||
}
|
||||
else if(data[3] == "NLAND")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(15706));
|
||||
}
|
||||
else if(data[3] == "NOCEAN")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(18476));
|
||||
}
|
||||
else if(data[3] == "NAIR")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(18475));
|
||||
}
|
||||
else if(data[3] == "NM")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14818));
|
||||
}
|
||||
else if(data[3] == "NL")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdAndInsertOnly(14697,data[4]));
|
||||
}
|
||||
else if(data[3] == "NAIL")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14820));
|
||||
}
|
||||
else if(data[3] == "NDL")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdAndInsertOnly(14696,data[4]));
|
||||
}
|
||||
else if(data[3] == "NP")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(19656));
|
||||
}
|
||||
else
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14816));
|
||||
}
|
||||
GuiManager.grayOutHudItemsForPrivateLobby(false);
|
||||
}
|
||||
break;
|
||||
case "qj":
|
||||
GuiManager.setSwapBtnGray(true);
|
||||
AvatarManager.joiningNewRoom = false;
|
||||
RoomXtCommManager._loadingNewRoom = false;
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(data[2] != 0)
|
||||
{
|
||||
QuestManager.handleQuestJoinResponse(data,AdventureJoin.NORMAL_TYPE,data[5]);
|
||||
}
|
||||
else if(data[3] == "NV")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14816));
|
||||
}
|
||||
else if(data[3] == "NLAND")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(15706));
|
||||
}
|
||||
else if(data[3] == "NOCEAN")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(18476));
|
||||
}
|
||||
else if(data[3] == "NAIR")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(18475));
|
||||
}
|
||||
else if(data[3] == "NM")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14823));
|
||||
}
|
||||
else if(data[3] == "NL")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdAndInsertOnly(14697,data[4]));
|
||||
}
|
||||
else if(data[3] == "NAIL")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14820));
|
||||
}
|
||||
else if(data[3] == "NDL")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdAndInsertOnly(14696,data[4]));
|
||||
}
|
||||
else if(data[3] == "NDLERR")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,"Total user var bits exceeded - increase support for additional levels!");
|
||||
}
|
||||
else if(data[3] == "NP")
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(19656));
|
||||
}
|
||||
else
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14816));
|
||||
}
|
||||
break;
|
||||
case "qjx":
|
||||
GuiManager.setSwapBtnGray(false);
|
||||
QuestManager.handleQuestJoinCancelResponse(data);
|
||||
break;
|
||||
case "qw":
|
||||
QuestManager.handleQuestWaitResponse(data);
|
||||
if(_autoStartQuestOnNextWaitResponse)
|
||||
{
|
||||
_autoStartQuestOnNextWaitResponse = false;
|
||||
sendQuestStartRequest();
|
||||
}
|
||||
break;
|
||||
case "qs":
|
||||
GuiManager.setSwapBtnGray(false);
|
||||
questStartResponse(data);
|
||||
QuestManager.handleQuestStartResponse(data);
|
||||
break;
|
||||
case "qat":
|
||||
questActorTriggeredResponse(data);
|
||||
break;
|
||||
case "qcmd":
|
||||
QuestManager.handleCommand(data,false);
|
||||
break;
|
||||
case "qcmdVT":
|
||||
QuestManager.handleCommand(data,true);
|
||||
break;
|
||||
case "qp":
|
||||
QuestManager.handleLaunchProjectile(data);
|
||||
break;
|
||||
case "qm":
|
||||
QuestManager.handleSwipe(data);
|
||||
break;
|
||||
case "quxp":
|
||||
QuestManager.handleXpUpdate(data);
|
||||
break;
|
||||
case "quhp":
|
||||
QuestManager.handleHealthUpdate(data,false);
|
||||
break;
|
||||
case "qrspn":
|
||||
QuestManager.handleHealthUpdate(data,true);
|
||||
break;
|
||||
case "qad":
|
||||
QuestManager.handleActorDeath(data);
|
||||
break;
|
||||
case "qx":
|
||||
break;
|
||||
case "qxt":
|
||||
QuestManager.handleExitByType(data);
|
||||
break;
|
||||
case "qspn":
|
||||
QuestManager.handleSpawn(data);
|
||||
break;
|
||||
case "qatt":
|
||||
QuestManager.handleQuestActorTriggerTreasure(data);
|
||||
break;
|
||||
case "qusu":
|
||||
QuestManager.handleStatsUpdate(data);
|
||||
break;
|
||||
case "qulu":
|
||||
QuestManager.handleLevelUp(data);
|
||||
break;
|
||||
case "qporbs":
|
||||
QuestManager.handleOrbsUpdate(data);
|
||||
break;
|
||||
case "qpup":
|
||||
QuestManager.handlePickUpItem(data);
|
||||
break;
|
||||
case "qsnd":
|
||||
QuestManager.playSound(data[2],null,data[3] == "1");
|
||||
break;
|
||||
case "qmusic":
|
||||
QuestManager.playMusic(data[2]);
|
||||
break;
|
||||
case "qswfs":
|
||||
QuestManager.handleSetSwfState(data);
|
||||
break;
|
||||
case "qmlib":
|
||||
QuestManager.handleLoadMediaLib(data);
|
||||
break;
|
||||
case "qprr":
|
||||
QuestManager.handleQuestPlayerRequestRespawn(data);
|
||||
break;
|
||||
case "qpd":
|
||||
QuestManager.handleQuestPlayerDead(data);
|
||||
break;
|
||||
case "qsp":
|
||||
QuestManager.handleQuestSetPath(data);
|
||||
break;
|
||||
case "qps":
|
||||
QuestManager.handlePlantSeed(data);
|
||||
break;
|
||||
case "qpa":
|
||||
QuestManager.handlePlantAte(data[2],data[3]);
|
||||
break;
|
||||
case "qbzap":
|
||||
QuestManager.handleBeamZap(data);
|
||||
break;
|
||||
case "qpzap":
|
||||
QuestManager.handlePhantomZap(data);
|
||||
break;
|
||||
case "qdroporb":
|
||||
QuestManager.handleDropOrb(data);
|
||||
break;
|
||||
case "qpgift":
|
||||
QuestManager.handlePickGift(data);
|
||||
break;
|
||||
case "qplq":
|
||||
QuestManager.handlePlayerLeftQuest(data);
|
||||
break;
|
||||
case "qrc":
|
||||
QuestManager.handleQuestRoomChange(data);
|
||||
break;
|
||||
case "qviu":
|
||||
QuestManager.handleQuestVolumeInteractionUpdate(data);
|
||||
break;
|
||||
case "qtorch":
|
||||
QuestManager.handleQuestTorch(data);
|
||||
break;
|
||||
case "qgi":
|
||||
questPickUpItem(data[2]);
|
||||
break;
|
||||
case "qsndpk":
|
||||
QuestManager.loadQuestSfx(data[2]);
|
||||
break;
|
||||
case "qicon":
|
||||
QuestManager.handleActorIcon(data[2],data[3]);
|
||||
break;
|
||||
case "qseed":
|
||||
QuestManager.handleGiveSeed(data[2],data[3],data[4]);
|
||||
break;
|
||||
case "qmi":
|
||||
QuestManager.handleMovedItemList(data as Array);
|
||||
break;
|
||||
case "qepr":
|
||||
QuestManager.handlePlantEatRecoil(data[2]);
|
||||
break;
|
||||
case "qplayswf":
|
||||
QuestManager.handlePlaySwf(data[2]);
|
||||
break;
|
||||
case "qshake":
|
||||
QuestManager.handleShake(data[2]);
|
||||
break;
|
||||
case "qaward":
|
||||
QuestManager.handleAward(data[2],data[3]);
|
||||
break;
|
||||
case "qposturi":
|
||||
QuestManager.handlePostUri(data[2]);
|
||||
break;
|
||||
case "qpreloadswf":
|
||||
QuestManager.handlPreloadSwf(data[2]);
|
||||
break;
|
||||
case "qfade":
|
||||
QuestManager.handleFade(data[2] == 1);
|
||||
break;
|
||||
case "qavsw":
|
||||
QuestManager.handleAvSwitch(data);
|
||||
}
|
||||
}
|
||||
|
||||
private static function questStartResponse(data:Object) : void
|
||||
{
|
||||
var timeStamp:String = null;
|
||||
var actorDictionary:Dictionary = null;
|
||||
var actorData:Object = null;
|
||||
var actorID:String = null;
|
||||
var actorType:int = 0;
|
||||
var actorDefId:int = 0;
|
||||
var actorDefName:String = null;
|
||||
var actorState:int = 0;
|
||||
var actorVisible:Boolean = false;
|
||||
var actorRequireClick:Boolean = false;
|
||||
var actorPath:String = null;
|
||||
var actorSwfState:String = null;
|
||||
var i:int = 2;
|
||||
var scriptDefId:int = int(data[i++]);
|
||||
var playerCount:int = int(data[i++]);
|
||||
var actorCount:int = int(data[i++]);
|
||||
if(actorCount >= 0)
|
||||
{
|
||||
timeStamp = data[i++];
|
||||
for(actorDictionary = new Dictionary(); actorCount > 0; )
|
||||
{
|
||||
actorData = new Object();
|
||||
actorID = data[i++];
|
||||
actorType = int(data[i++]);
|
||||
actorDefId = 0;
|
||||
actorDefName = null;
|
||||
if(actorType == QuestActor.QUEST_ACTOR_TYPE_SPEAKER)
|
||||
{
|
||||
actorDefName = data[i++];
|
||||
}
|
||||
else
|
||||
{
|
||||
actorDefId = int(data[i++]);
|
||||
}
|
||||
actorState = int(data[i++]);
|
||||
actorVisible = data[i++] == 1;
|
||||
actorRequireClick = data[i++] == 1;
|
||||
actorPath = data[i++];
|
||||
actorSwfState = data[i++];
|
||||
actorData.visible = actorVisible;
|
||||
actorData.requireClick = actorRequireClick;
|
||||
actorData.defId = actorDefId;
|
||||
actorData.defName = actorDefName;
|
||||
actorData.type = actorType;
|
||||
actorData.state = actorState;
|
||||
actorData.pathName = actorPath != "" ? actorPath : null;
|
||||
QuestManager.initInitialActorStatus(actorData,null);
|
||||
actorData.pendingSwfStateName = actorSwfState;
|
||||
actorDictionary[actorID] = actorData;
|
||||
actorCount--;
|
||||
}
|
||||
QuestManager.setActorDictionary(actorDictionary,timeStamp);
|
||||
QuestManager.hasJustJoinedQuest = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AvatarManager.joiningNewRoom = false;
|
||||
RoomXtCommManager._loadingNewRoom = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static function questActorTriggeredResponse(data:Object) : void
|
||||
{
|
||||
}
|
||||
|
||||
public static function questNPCDefResponse(dfdh:DefPacksDefHelper) : void
|
||||
{
|
||||
var npcDef:Object = null;
|
||||
var data:Object = null;
|
||||
var newDef:Object = dfdh.def;
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_NPC] = null;
|
||||
var npcDefs:Object = new Object();
|
||||
for each(data in dfdh.def)
|
||||
{
|
||||
npcDef = {
|
||||
"avatarRefId":int(data.avatarRefId),
|
||||
"backColor":Number(data.backColor),
|
||||
"backItemRefId":int(data.backItemRefId),
|
||||
"eyesColor":Number(data.eyesColor),
|
||||
"eyesItemRefId":int(data.eyesItemRefId),
|
||||
"legColor":Number(data.legColor),
|
||||
"legItemRefId":int(data.legItemRefId),
|
||||
"headColor":int(data.headColor),
|
||||
"headMediaRefId":uint(data.headMediaRefId),
|
||||
"headItemRefId":int(data.headItemRefId),
|
||||
"defId":int(data.id),
|
||||
"mediaRefId":int(data.mediaRefId),
|
||||
"neckColor":Number(data.neckColor),
|
||||
"neckItemRefId":int(data.neckItemRefId),
|
||||
"patternColor":Number(data.patternColor),
|
||||
"patternItemRefId":int(data.patternItemRefId),
|
||||
"tailColor":Number(data.tailColor),
|
||||
"tailItemRefId":int(data.tailItemRefId),
|
||||
"titleStrId":int(data.titleStrId),
|
||||
"type":int(data.type),
|
||||
"baseColor":int(data.baseColor),
|
||||
"hps":int(data.hps),
|
||||
"defense":int(data.defense),
|
||||
"xpValue":int(data.xpValue),
|
||||
"iconMediaRefId":int(data.iconMediaRefId),
|
||||
"level":int(data.level),
|
||||
"attackable":int(data.attackable),
|
||||
"damageTouch":int(data.damageTouch)
|
||||
};
|
||||
npcDefs[npcDef.defId] = npcDef;
|
||||
}
|
||||
QuestManager.npcDefs = npcDefs;
|
||||
}
|
||||
|
||||
public static function scriptResponse(dfdh:DefPacksDefHelper) : void
|
||||
{
|
||||
var scriptDef:Object = null;
|
||||
var data:Object = null;
|
||||
var newDef:Object = dfdh.def;
|
||||
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_SCRIPT] = null;
|
||||
var scriptDefs:Object = new Object();
|
||||
for each(data in newDef)
|
||||
{
|
||||
scriptDef = {
|
||||
"defId":int(data.id),
|
||||
"avatarLimit":int(data.avatarLimit),
|
||||
"avatarMin":int(data.avatarMin),
|
||||
"avatarType":int(data.avatarType),
|
||||
"descStrId":int(data.descStrId),
|
||||
"difficulty":int(data.difficulty),
|
||||
"levelMin":int(data.levelMin),
|
||||
"mediaRefId":int(data.mediaRefId),
|
||||
"time":int(data.time),
|
||||
"titleStrId":int(data.titleStrId),
|
||||
"hudType":int(data.hudType),
|
||||
"bannerMediaRefId":int(data.bannerMediaRefId),
|
||||
"membersOnly":(data.membersOnly == "1" ? true : false),
|
||||
"playAsPet":(data.playAsPet == "1" ? true : false)
|
||||
};
|
||||
scriptDefs[scriptDef.defId] = scriptDef;
|
||||
}
|
||||
_scriptDefs = scriptDefs;
|
||||
}
|
||||
|
||||
public static function roomJoined(inRoomName:String) : void
|
||||
{
|
||||
QuestManager.questRoomJoined(inRoomName.indexOf("quest_") == 0);
|
||||
}
|
||||
|
||||
public static function getScriptDef(id:int) : Object
|
||||
{
|
||||
return _scriptDefs[id];
|
||||
}
|
||||
|
||||
private static function searchQuestCache(defId:int) : Object
|
||||
{
|
||||
return _questCache[defId];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,338 @@
|
||||
package quest
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.filters.ColorMatrixFilter;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.Dictionary;
|
||||
import gui.GuiManager;
|
||||
import loader.MediaHelper;
|
||||
import room.RoomManagerWorld;
|
||||
|
||||
public class SeedInventoryHandling
|
||||
{
|
||||
|
||||
public const MAX_NUM_SEEDS:int = 5;
|
||||
|
||||
private var _seedsInventory:Dictionary;
|
||||
|
||||
private var _draggedSeed:MovieClip;
|
||||
|
||||
private var _mediaHelper:MediaHelper;
|
||||
|
||||
private var _mediaItems:Array;
|
||||
|
||||
private var _clickStartX:Number;
|
||||
|
||||
private var _clickStartY:Number;
|
||||
|
||||
public function SeedInventoryHandling()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(seedsInventory:Dictionary) : void
|
||||
{
|
||||
this._mediaItems = [];
|
||||
this._seedsInventory = seedsInventory;
|
||||
this.setupInventoryWindows();
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
var currWindow:MovieClip = null;
|
||||
if(Boolean(this._draggedSeed) && this._draggedSeed.parent == GuiManager.guiLayer)
|
||||
{
|
||||
GuiManager.guiLayer.removeChild(this._draggedSeed);
|
||||
}
|
||||
this._draggedSeed = null;
|
||||
for(var i:int = 0; i < this.MAX_NUM_SEEDS; i++)
|
||||
{
|
||||
currWindow = GuiManager.mainHud["inventoriesWindow" + i];
|
||||
if(Boolean(currWindow))
|
||||
{
|
||||
currWindow.removeEventListener(MouseEvent.MOUSE_DOWN,this.onSeedsClickStart);
|
||||
}
|
||||
}
|
||||
this._seedsInventory = null;
|
||||
}
|
||||
|
||||
public function rebuildInventory(seedsInventory:Dictionary) : void
|
||||
{
|
||||
this._seedsInventory = seedsInventory;
|
||||
this.setupInventoryWindows();
|
||||
}
|
||||
|
||||
public function removeLastDraggedSeed() : void
|
||||
{
|
||||
if(Boolean(this._draggedSeed))
|
||||
{
|
||||
this._draggedSeed.removeEventListener(MouseEvent.MOUSE_DOWN,this.onSeedsDragDown);
|
||||
this._draggedSeed.removeEventListener(MouseEvent.MOUSE_UP,this.onSeedsClickStartUp);
|
||||
this._draggedSeed.removeEventListener(MouseEvent.MOUSE_MOVE,this.onSeedMove);
|
||||
this._draggedSeed.stopDrag();
|
||||
if(this._draggedSeed.parent == GuiManager.guiLayer)
|
||||
{
|
||||
GuiManager.guiLayer.removeChild(this._draggedSeed);
|
||||
}
|
||||
this._draggedSeed = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function setupInventoryWindows() : void
|
||||
{
|
||||
var npcDef:Object = null;
|
||||
var seedMediaId:int = 0;
|
||||
var currWindow:MovieClip = null;
|
||||
var i:int = 0;
|
||||
var count:int = 0;
|
||||
var max:int = 0;
|
||||
var seedDef:String = null;
|
||||
var currChild:Object = null;
|
||||
var matrix:Array = null;
|
||||
this._mediaItems = [];
|
||||
for(seedDef in this._seedsInventory)
|
||||
{
|
||||
npcDef = QuestManager.getNPCDef(int(seedDef));
|
||||
if(Boolean(npcDef))
|
||||
{
|
||||
seedMediaId = int(npcDef.mediaRefId);
|
||||
currWindow = GuiManager.mainHud["inventoriesWindow" + i];
|
||||
if(currWindow != null && currWindow.numChildren > 0)
|
||||
{
|
||||
currChild = currWindow.getChildAt(0);
|
||||
if(currChild.hasOwnProperty("txt"))
|
||||
{
|
||||
count = int(this._seedsInventory[seedDef].count);
|
||||
max = int(this._seedsInventory[seedDef].max);
|
||||
currChild.txt.text = count + "/" + max;
|
||||
if(count == 0)
|
||||
{
|
||||
matrix = new Array();
|
||||
matrix = matrix.concat([0.33,0.33,0.33,0,0]);
|
||||
matrix = matrix.concat([0.33,0.33,0.33,0,0]);
|
||||
matrix = matrix.concat([0.33,0.33,0.33,0,0]);
|
||||
matrix = matrix.concat([0,0,0,1,0]);
|
||||
currChild.filters = [new ColorMatrixFilter(matrix)];
|
||||
currWindow.mouseEnabled = false;
|
||||
currWindow.mouseChildren = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(count >= max)
|
||||
{
|
||||
currChild.gotoAndPlay("on");
|
||||
}
|
||||
currChild.filters = null;
|
||||
currWindow.mouseEnabled = true;
|
||||
currWindow.mouseChildren = true;
|
||||
}
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(seedMediaId != 0)
|
||||
{
|
||||
this._mediaHelper = new MediaHelper();
|
||||
this._mediaHelper.init(seedMediaId,this.onSeedLoaded,{
|
||||
"index":i,
|
||||
"contIcon":true,
|
||||
"defId":int(seedDef)
|
||||
});
|
||||
this._mediaItems[i] = this._mediaHelper;
|
||||
this._mediaHelper = new MediaHelper();
|
||||
this._mediaHelper.init(seedMediaId,this.onSeedLoaded,{
|
||||
"index":i,
|
||||
"contIcon":false,
|
||||
"defId":int(seedDef)
|
||||
});
|
||||
this._mediaItems[i + 1] = this._mediaHelper;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
while(i < this.MAX_NUM_SEEDS)
|
||||
{
|
||||
currWindow = GuiManager.mainHud["inventoriesWindow" + i];
|
||||
if(currWindow != null)
|
||||
{
|
||||
currWindow.mouseEnabled = false;
|
||||
currWindow.mouseChildren = false;
|
||||
currWindow.visible = false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
private function onSeedLoaded(img:MovieClip) : void
|
||||
{
|
||||
var seedCont:MovieClip = null;
|
||||
var currWindow:MovieClip = null;
|
||||
var count:int = 0;
|
||||
var max:int = 0;
|
||||
var matrix:Array = null;
|
||||
if(Boolean(img))
|
||||
{
|
||||
img.setAsIcon();
|
||||
if(Boolean(img.passback.contIcon))
|
||||
{
|
||||
seedCont = GETDEFINITIONBYNAME("vftCont");
|
||||
currWindow = GuiManager.mainHud["inventoriesWindow" + img.passback.index];
|
||||
count = int(this._seedsInventory[img.passback.defId].count);
|
||||
max = int(this._seedsInventory[img.passback.defId].max);
|
||||
seedCont.itemWindow.addChild(img.getNPC());
|
||||
seedCont.txt.text = count + "/" + max;
|
||||
if(count == 0)
|
||||
{
|
||||
matrix = new Array();
|
||||
matrix = matrix.concat([0.33,0.33,0.33,0,0]);
|
||||
matrix = matrix.concat([0.33,0.33,0.33,0,0]);
|
||||
matrix = matrix.concat([0.33,0.33,0.33,0,0]);
|
||||
matrix = matrix.concat([0,0,0,1,0]);
|
||||
seedCont.filters = [new ColorMatrixFilter(matrix)];
|
||||
if(currWindow != null)
|
||||
{
|
||||
currWindow.mouseEnabled = false;
|
||||
currWindow.mouseChildren = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(count >= max)
|
||||
{
|
||||
seedCont.gotoAndPlay("on");
|
||||
}
|
||||
seedCont.filters = null;
|
||||
if(currWindow != null)
|
||||
{
|
||||
currWindow.mouseEnabled = true;
|
||||
currWindow.mouseChildren = true;
|
||||
}
|
||||
}
|
||||
if(currWindow != null)
|
||||
{
|
||||
while(currWindow.numChildren > 0)
|
||||
{
|
||||
currWindow.removeChildAt(0);
|
||||
}
|
||||
currWindow.addChild(seedCont);
|
||||
currWindow.addEventListener(MouseEvent.MOUSE_DOWN,this.onSeedsClickStart,false,0,true);
|
||||
currWindow.visible = true;
|
||||
}
|
||||
}
|
||||
else if(GuiManager.mainHud["inventoriesWindow" + img.passback.index] != null)
|
||||
{
|
||||
GuiManager.mainHud["inventoriesWindow" + img.passback.index].dragIcon = img;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onSeedsClickStart(evt:MouseEvent) : void
|
||||
{
|
||||
evt.stopPropagation();
|
||||
this._clickStartX = evt.stageX;
|
||||
this._clickStartY = evt.stageY;
|
||||
if(this._draggedSeed == null || this._draggedSeed.windowName != evt.currentTarget.name)
|
||||
{
|
||||
if(Boolean(this._draggedSeed) && this._draggedSeed.parent == GuiManager.guiLayer)
|
||||
{
|
||||
GuiManager.guiLayer.removeChild(this._draggedSeed);
|
||||
}
|
||||
this._draggedSeed = evt.currentTarget.dragIcon.getNPC();
|
||||
this._draggedSeed.custom = {
|
||||
"prevPositionX":0,
|
||||
"prevPositionY":0,
|
||||
"xOut":false,
|
||||
"currWindow":evt.currentTarget
|
||||
};
|
||||
this._draggedSeed.addEventListener(MouseEvent.MOUSE_UP,this.onSeedsClickStartUp,false,0,true);
|
||||
this._draggedSeed.addEventListener(MouseEvent.MOUSE_MOVE,this.onSeedMove,false,0,true);
|
||||
this._draggedSeed.addEventListener(MouseEvent.MOUSE_DOWN,this.onSeedsDragDown,false,0,true);
|
||||
this._draggedSeed.x = evt.currentTarget.x;
|
||||
this._draggedSeed.y = evt.currentTarget.y;
|
||||
this._draggedSeed.custom.prevPositionX = 0;
|
||||
this._draggedSeed.custom.prevPositionY = 0;
|
||||
this._draggedSeed.custom.xOut = false;
|
||||
evt.currentTarget.dragIcon.setAsIcon();
|
||||
this._draggedSeed.passback = evt.currentTarget.dragIcon.passback;
|
||||
GuiManager.guiLayer.addChild(this._draggedSeed);
|
||||
}
|
||||
this._draggedSeed.startDrag(true);
|
||||
QuestManager.playSound("ajq_boomSeedSelect");
|
||||
}
|
||||
|
||||
private function onSeedsDragDown(evt:MouseEvent) : void
|
||||
{
|
||||
evt.stopPropagation();
|
||||
}
|
||||
|
||||
private function onSeedsClickStartUp(evt:MouseEvent) : void
|
||||
{
|
||||
evt.stopPropagation();
|
||||
if(Math.abs(this._clickStartX - evt.stageX) > 2 || Math.abs(this._clickStartY - evt.stageY) > 2)
|
||||
{
|
||||
this.onSeedsClickEnd(evt);
|
||||
}
|
||||
else if(this._draggedSeed != null)
|
||||
{
|
||||
this._clickStartX = -99999;
|
||||
this._clickStartY = -99999;
|
||||
}
|
||||
}
|
||||
|
||||
private function onSeedMove(evt:MouseEvent) : void
|
||||
{
|
||||
var worldAim:Point = null;
|
||||
evt.stopPropagation();
|
||||
if(Math.abs(this._clickStartX - evt.stageX) > 2 || Math.abs(this._clickStartY - evt.stageY) > 2)
|
||||
{
|
||||
this._clickStartX = -99999;
|
||||
this._clickStartY = -99999;
|
||||
}
|
||||
var deltaX:Number = evt.stageX - this._draggedSeed.custom.prevPositionX;
|
||||
var deltaY:Number = evt.stageY - this._draggedSeed.custom.prevPositionY;
|
||||
var deltaSquared:Number = deltaX * deltaX + deltaY * deltaY;
|
||||
if(deltaSquared > 9)
|
||||
{
|
||||
this._draggedSeed.custom.prevPositionX = evt.stageX;
|
||||
this._draggedSeed.custom.prevPositionY = evt.stageY;
|
||||
worldAim = RoomManagerWorld.instance.convertScreenToWorldSpace(evt.stageX,evt.stageY);
|
||||
if(QuestManager.validatePlantSeedLocation(worldAim) == false)
|
||||
{
|
||||
if(!evt.currentTarget.custom.xOut)
|
||||
{
|
||||
evt.currentTarget.custom.currWindow.dragIcon.setAsIconX();
|
||||
evt.currentTarget.custom.xOut = true;
|
||||
}
|
||||
}
|
||||
else if(Boolean(evt.currentTarget.custom.xOut))
|
||||
{
|
||||
evt.currentTarget.custom.currWindow.dragIcon.setAsIcon();
|
||||
evt.currentTarget.custom.xOut = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onSeedsClickEnd(evt:MouseEvent) : void
|
||||
{
|
||||
var worldAim:Point = null;
|
||||
var isHit:Boolean = false;
|
||||
evt.stopPropagation();
|
||||
if(Boolean(this._draggedSeed))
|
||||
{
|
||||
worldAim = RoomManagerWorld.instance.convertScreenToWorldSpace(evt.stageX,evt.stageY);
|
||||
isHit = this._draggedSeed.hitTestObject(this._draggedSeed.custom.currWindow);
|
||||
if(!isHit)
|
||||
{
|
||||
if(QuestManager.validatePlantSeedLocation(worldAim))
|
||||
{
|
||||
QuestXtCommManager.sendPlantSeed(this._draggedSeed.passback.defId,worldAim.x,worldAim.y);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.removeLastDraggedSeed();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user