mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 09: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,101 @@
|
||||
package room
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.text.TextField;
|
||||
|
||||
public class DebugGUICheckbox extends Sprite
|
||||
{
|
||||
|
||||
private static const BOX_COLOR:Number = 16777215;
|
||||
|
||||
private static const CHK_COLOR:Number = 0;
|
||||
|
||||
private static const CHKBOX_WIDTH:Number = 20;
|
||||
|
||||
private static const CHKBOX_HEIGHT:Number = 20;
|
||||
|
||||
private var _box:Sprite;
|
||||
|
||||
private var _check:Sprite;
|
||||
|
||||
private var _label:TextField;
|
||||
|
||||
private var _visible:Boolean;
|
||||
|
||||
public var valueChangedCallback:Function;
|
||||
|
||||
public function DebugGUICheckbox()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(initParent:DisplayObjectContainer, initValueChangedCallback:Function, initLabel:String, initChecked:Boolean = false, initVisible:Boolean = false) : void
|
||||
{
|
||||
this._box = new Sprite();
|
||||
this._check = new Sprite();
|
||||
with(this._box.graphics)
|
||||
{
|
||||
beginFill(BOX_COLOR);
|
||||
drawRect(0,0,CHKBOX_WIDTH,CHKBOX_HEIGHT);
|
||||
endFill();
|
||||
}
|
||||
with(this._check.graphics)
|
||||
{
|
||||
lineStyle(2,CHK_COLOR);
|
||||
moveTo(0,0);
|
||||
lineTo(CHKBOX_WIDTH,CHKBOX_HEIGHT);
|
||||
}
|
||||
addEventListener(MouseEvent.MOUSE_DOWN,this.chkboxMouseDownHandler,false,0,true);
|
||||
this._box.addChild(this._check);
|
||||
addChild(this._box);
|
||||
this._label = new TextField();
|
||||
this._label.x = CHKBOX_WIDTH;
|
||||
this._label.height = CHKBOX_HEIGHT;
|
||||
this._label.text = initLabel;
|
||||
this._label.selectable = false;
|
||||
addChild(this._label);
|
||||
this._check.visible = initChecked;
|
||||
visible = initVisible;
|
||||
this.valueChangedCallback = initValueChangedCallback;
|
||||
initParent.addChild(this);
|
||||
}
|
||||
|
||||
public function get checked() : Boolean
|
||||
{
|
||||
return this._check.visible;
|
||||
}
|
||||
|
||||
public function set checked(setChecked:Boolean) : void
|
||||
{
|
||||
this._check.visible = setChecked;
|
||||
}
|
||||
|
||||
public function get label() : TextField
|
||||
{
|
||||
return this._label;
|
||||
}
|
||||
|
||||
public function toggleVisiblity() : void
|
||||
{
|
||||
visible = !visible;
|
||||
}
|
||||
|
||||
public function toggleChecked() : void
|
||||
{
|
||||
this._check.visible = !this._check.visible;
|
||||
}
|
||||
|
||||
private function chkboxMouseDownHandler(m:MouseEvent) : void
|
||||
{
|
||||
m.stopPropagation();
|
||||
this._check.visible = !this._check.visible;
|
||||
if(this.valueChangedCallback != null)
|
||||
{
|
||||
this.valueChangedCallback(this._check.visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
package room
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.text.TextField;
|
||||
import flash.ui.Keyboard;
|
||||
|
||||
public class DebugGUISlider
|
||||
{
|
||||
|
||||
private static const SLIDER_X:Number = 400;
|
||||
|
||||
private static const SLIDER_Y:Number = 200;
|
||||
|
||||
private static const NUB_COLOR:Number = 16776960;
|
||||
|
||||
private static const NUB_WIDTH:Number = 10;
|
||||
|
||||
private static const NUB_HEIGHT:Number = 20;
|
||||
|
||||
private static const SLIDER_WIDTH:Number = 120;
|
||||
|
||||
private static const SLIDER_MAX:Number = 1;
|
||||
|
||||
private static const SLIDER_INIT:Number = 1;
|
||||
|
||||
private var _drag:Boolean;
|
||||
|
||||
private var _slider:Sprite;
|
||||
|
||||
private var _nub:Sprite;
|
||||
|
||||
private var _value:TextField;
|
||||
|
||||
private var _visible:Boolean;
|
||||
|
||||
private var _layerManager:LayerManager;
|
||||
|
||||
public var valueChangedCallback:Function;
|
||||
|
||||
public function DebugGUISlider()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(initParent:Object, initValueChangedCallback:Function, initVisible:Boolean = false) : void
|
||||
{
|
||||
this._layerManager = LayerManager(initParent);
|
||||
initParent = initParent.fps;
|
||||
this._slider = new Sprite();
|
||||
this._nub = new Sprite();
|
||||
with(this._nub.graphics)
|
||||
{
|
||||
beginFill(NUB_COLOR);
|
||||
drawRect(-NUB_WIDTH * 0.5,-NUB_HEIGHT * 0.5,NUB_WIDTH,NUB_HEIGHT);
|
||||
}
|
||||
this._nub.x = SLIDER_WIDTH * SLIDER_INIT;
|
||||
this._nub.y = 0;
|
||||
with(this._slider.graphics)
|
||||
{
|
||||
lineStyle(2);
|
||||
moveTo(0,0);
|
||||
lineTo(SLIDER_WIDTH,0);
|
||||
beginFill(0,0);
|
||||
drawRect(-NUB_WIDTH,-NUB_HEIGHT,SLIDER_WIDTH + NUB_WIDTH + NUB_WIDTH,NUB_HEIGHT + NUB_HEIGHT);
|
||||
}
|
||||
this._slider.x = SLIDER_X;
|
||||
this._slider.y = SLIDER_Y;
|
||||
gMainFrame.stage.addEventListener(KeyboardEvent.KEY_DOWN,this.onKeyDown,false,0,true);
|
||||
this._slider.addEventListener(MouseEvent.MOUSE_DOWN,this.sliderMouseDownHandler,false,0,true);
|
||||
this._slider.addEventListener(MouseEvent.MOUSE_MOVE,this.sliderMouseMoveHandler,false,0,true);
|
||||
this._slider.addEventListener(MouseEvent.MOUSE_OUT,this.sliderMouseOutHandler,false,0,true);
|
||||
this._slider.addEventListener(MouseEvent.MOUSE_UP,this.sliderMouseUpHandler,false,0,true);
|
||||
this._slider.addChild(this._nub);
|
||||
initParent.addChild(this._slider);
|
||||
this._value = new TextField();
|
||||
this._value.x = SLIDER_X + SLIDER_WIDTH + NUB_WIDTH + NUB_WIDTH + NUB_WIDTH;
|
||||
this._value.y = this._slider.y;
|
||||
this._value.width = 32;
|
||||
this._value.text = String(SLIDER_INIT);
|
||||
initParent.addChild(this._value);
|
||||
this._visible = initVisible;
|
||||
this._slider.visible = this._visible;
|
||||
this._value.visible = this._visible;
|
||||
this.valueChangedCallback = initValueChangedCallback;
|
||||
}
|
||||
|
||||
public function toggleVisiblity() : void
|
||||
{
|
||||
this._nub.x = SLIDER_WIDTH * this._layerManager.bkg.scaleX;
|
||||
this._value.text = String(this._layerManager.bkg.scaleX);
|
||||
this._visible = !this._visible;
|
||||
this._slider.visible = this._visible;
|
||||
this._value.visible = this._visible;
|
||||
}
|
||||
|
||||
private function sliderMouseDownHandler(m:MouseEvent) : void
|
||||
{
|
||||
this._drag = true;
|
||||
this.sliderMouseMoveHandler(m);
|
||||
}
|
||||
|
||||
private function onKeyDown(evt:KeyboardEvent) : void
|
||||
{
|
||||
var hasChanged:Boolean = false;
|
||||
var sliderVal:Number = NaN;
|
||||
if(evt.keyCode == Keyboard.NUMPAD_ADD)
|
||||
{
|
||||
this._nub.x += 1;
|
||||
hasChanged = true;
|
||||
}
|
||||
else if(evt.keyCode == Keyboard.NUMPAD_SUBTRACT)
|
||||
{
|
||||
this._nub.x -= 1;
|
||||
hasChanged = true;
|
||||
}
|
||||
else if(evt.keyCode == Keyboard.EQUAL)
|
||||
{
|
||||
this._nub.x += 0.1;
|
||||
hasChanged = true;
|
||||
}
|
||||
else if(evt.keyCode == Keyboard.MINUS)
|
||||
{
|
||||
this._nub.x -= 0.1;
|
||||
hasChanged = true;
|
||||
}
|
||||
if(hasChanged)
|
||||
{
|
||||
sliderVal = this._nub.x * SLIDER_MAX / SLIDER_WIDTH;
|
||||
this._layerManager.bkg.scaleX = this._layerManager.bkg.scaleY = sliderVal;
|
||||
this._value.text = String(sliderVal);
|
||||
}
|
||||
}
|
||||
|
||||
private function sliderMouseMoveHandler(m:MouseEvent) : void
|
||||
{
|
||||
var sliderX:Number = NaN;
|
||||
var sliderVal:Number = NaN;
|
||||
if(this._drag && m.target is DisplayObject && this._slider.contains(DisplayObject(m.target)))
|
||||
{
|
||||
m.stopPropagation();
|
||||
sliderX = m.localX;
|
||||
if(m.target == this._nub)
|
||||
{
|
||||
sliderX += this._nub.x;
|
||||
}
|
||||
if(sliderX < 0)
|
||||
{
|
||||
sliderX = 0;
|
||||
}
|
||||
if(sliderX > SLIDER_WIDTH)
|
||||
{
|
||||
sliderX = SLIDER_WIDTH;
|
||||
}
|
||||
this._nub.x = sliderX;
|
||||
sliderVal = sliderX * SLIDER_MAX / SLIDER_WIDTH;
|
||||
this._layerManager.bkg.scaleX = this._layerManager.bkg.scaleY = sliderVal;
|
||||
this._value.text = String(sliderVal);
|
||||
}
|
||||
}
|
||||
|
||||
private function sliderMouseOutHandler(m:MouseEvent) : void
|
||||
{
|
||||
if(!m.relatedObject || !this._slider.contains(m.relatedObject))
|
||||
{
|
||||
this._drag = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function sliderMouseUpHandler(m:MouseEvent) : void
|
||||
{
|
||||
this._drag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package room
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.text.TextField;
|
||||
|
||||
public class DebugGUITextbox extends Sprite
|
||||
{
|
||||
|
||||
private static const BG_COLOR:Number = 16777215;
|
||||
|
||||
private static const TXT_COLOR:Number = 0;
|
||||
|
||||
private static const TXTBOX_HEIGHT:Number = 22;
|
||||
|
||||
private var _bg:Sprite;
|
||||
|
||||
private var _txt:TextField;
|
||||
|
||||
public function DebugGUITextbox()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(initParent:DisplayObjectContainer, initTxtText:String = "", initVisible:Boolean = false, initSelectable:Boolean = false, initNoBackground:Boolean = false, initWidth:Number = 800) : void
|
||||
{
|
||||
if(!initNoBackground)
|
||||
{
|
||||
this._bg = new Sprite();
|
||||
with(this._bg.graphics)
|
||||
{
|
||||
|
||||
beginFill(BG_COLOR);
|
||||
drawRect(0,0,initWidth,TXTBOX_HEIGHT);
|
||||
}
|
||||
addChild(this._bg);
|
||||
}
|
||||
this._txt = new TextField();
|
||||
with(this._txt)
|
||||
{
|
||||
text = initTxtText;
|
||||
textColor = TXT_COLOR;
|
||||
width = initWidth;
|
||||
height = TXTBOX_HEIGHT;
|
||||
if(!initSelectable)
|
||||
{
|
||||
mouseEnabled = false;
|
||||
selectable = false;
|
||||
}
|
||||
}
|
||||
addChild(this._txt);
|
||||
visible = initVisible;
|
||||
addEventListener(MouseEvent.MOUSE_DOWN,this.txtboxMouseDownHandler,false,0,true);
|
||||
initParent.addChild(this);
|
||||
}
|
||||
|
||||
public function toggleVisiblity() : void
|
||||
{
|
||||
visible = !visible;
|
||||
}
|
||||
|
||||
public function get txt() : TextField
|
||||
{
|
||||
return this._txt;
|
||||
}
|
||||
|
||||
public function get text() : String
|
||||
{
|
||||
return this._txt.text;
|
||||
}
|
||||
|
||||
public function set text(setStr:String) : void
|
||||
{
|
||||
this._txt.text = setStr;
|
||||
}
|
||||
|
||||
private function txtboxMouseDownHandler(m:MouseEvent) : void
|
||||
{
|
||||
m.stopPropagation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,29 @@
|
||||
package room
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class DenItemHolderEvent extends Event
|
||||
{
|
||||
|
||||
public static const ITEM_REMOVED:String = "OnItemRemoved";
|
||||
|
||||
public static const SAVE_STATE:String = "OnSaveState";
|
||||
|
||||
public var id:uint;
|
||||
|
||||
public var refId:int;
|
||||
|
||||
public var array:Array;
|
||||
|
||||
public function DenItemHolderEvent(type:String)
|
||||
{
|
||||
super(type);
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new DenItemHolderEvent(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
package room
|
||||
{
|
||||
import com.sbi.graphics.SortLayer;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.Shape;
|
||||
|
||||
public class LayerManager
|
||||
{
|
||||
|
||||
private var _layer_bkg:DisplayLayer;
|
||||
|
||||
private var _layer_room_bkg:DisplayLayer;
|
||||
|
||||
private var _layer_room_bkg_group:DisplayLayer;
|
||||
|
||||
private var _layer_room_bkg_main:DisplayLayer;
|
||||
|
||||
private var _layer_room_avatars:SortLayer;
|
||||
|
||||
private var _layer_room_preview_avatar:SortLayer;
|
||||
|
||||
private var _layer_room_preview_flying_avatar:SortLayer;
|
||||
|
||||
private var _layer_room_fg:DisplayLayer;
|
||||
|
||||
private var _layer_flying_avatars:SortLayer;
|
||||
|
||||
private var _layer_room_super_fg:DisplayLayer;
|
||||
|
||||
private var _layer_room_chat:DisplayLayer;
|
||||
|
||||
private var _layer_room_orbs:DisplayLayer;
|
||||
|
||||
private var _layer_worldGame:DisplayLayer;
|
||||
|
||||
private var _layer_gui:DisplayLayer;
|
||||
|
||||
private var _layer_fps:DisplayLayer;
|
||||
|
||||
private var _layer_debug:DisplayLayer;
|
||||
|
||||
private var _debugShape:Shape;
|
||||
|
||||
public function LayerManager(view:DisplayObjectContainer, loadLayer:DisplayLayer)
|
||||
{
|
||||
super();
|
||||
this._layer_bkg = new DisplayLayer();
|
||||
this._layer_room_bkg = new DisplayLayer();
|
||||
this._layer_room_bkg_group = new DisplayLayer();
|
||||
this._layer_room_bkg_main = new DisplayLayer();
|
||||
this._layer_room_avatars = new SortLayer();
|
||||
this._layer_room_preview_avatar = new SortLayer();
|
||||
this._layer_room_preview_flying_avatar = new SortLayer();
|
||||
this._layer_room_fg = new DisplayLayer();
|
||||
this._layer_room_super_fg = new DisplayLayer();
|
||||
this._layer_flying_avatars = new SortLayer();
|
||||
this._layer_room_chat = new DisplayLayer();
|
||||
this._layer_room_orbs = new DisplayLayer();
|
||||
this._layer_room_orbs.mouseEnabled = false;
|
||||
this._layer_worldGame = new DisplayLayer();
|
||||
this._layer_gui = new DisplayLayer();
|
||||
this._layer_fps = new DisplayLayer();
|
||||
view.addChildAt(this._layer_bkg,view.getChildIndex(loadLayer));
|
||||
this._layer_bkg.addChild(this._layer_room_bkg);
|
||||
this._layer_bkg.addChild(this._layer_room_bkg_group);
|
||||
this._layer_room_bkg_group.addChild(this._layer_room_bkg_main);
|
||||
this._layer_room_bkg_group.addChild(this._layer_room_avatars);
|
||||
this._layer_room_bkg_group.addChild(this._layer_room_preview_avatar);
|
||||
this._layer_bkg.addChild(this._layer_room_fg);
|
||||
this._layer_bkg.addChild(this._layer_flying_avatars);
|
||||
this._layer_bkg.addChild(this._layer_room_preview_flying_avatar);
|
||||
this._layer_bkg.addChild(this._layer_room_super_fg);
|
||||
this._layer_bkg.addChild(this._layer_room_chat);
|
||||
this._layer_bkg.addChild(this._layer_room_orbs);
|
||||
this._layer_room_fg.mouseChildren = false;
|
||||
this._layer_room_fg.mouseEnabled = false;
|
||||
this._layer_room_super_fg.mouseChildren = false;
|
||||
this._layer_room_super_fg.mouseEnabled = false;
|
||||
view.addChildAt(this._layer_worldGame,view.getChildIndex(loadLayer));
|
||||
view.addChildAt(this._layer_gui,view.getChildIndex(loadLayer));
|
||||
this._layer_debug = new DisplayLayer();
|
||||
this._layer_fps.addChild(this._layer_debug);
|
||||
view.stage.addChild(this._layer_fps);
|
||||
this._debugShape = new Shape();
|
||||
}
|
||||
|
||||
public function showAvatarsAndRelatedItems(show:Boolean) : void
|
||||
{
|
||||
this._layer_flying_avatars.visible = show;
|
||||
this._layer_room_chat.visible = show;
|
||||
this._layer_room_orbs.visible = show;
|
||||
this._layer_room_avatars.visible = show;
|
||||
this._layer_room_bkg_main.visible = show;
|
||||
this._layer_room_preview_avatar.visible = !show;
|
||||
this._layer_room_preview_flying_avatar.visible = !show;
|
||||
}
|
||||
|
||||
public function get gui() : DisplayLayer
|
||||
{
|
||||
return this._layer_gui;
|
||||
}
|
||||
|
||||
public function get bkg() : DisplayLayer
|
||||
{
|
||||
return this._layer_bkg;
|
||||
}
|
||||
|
||||
public function get fps() : DisplayLayer
|
||||
{
|
||||
return this._layer_fps;
|
||||
}
|
||||
|
||||
public function get room_bkg_group() : DisplayLayer
|
||||
{
|
||||
return this._layer_room_bkg_group;
|
||||
}
|
||||
|
||||
public function get room_bkg_main() : DisplayLayer
|
||||
{
|
||||
return this._layer_room_bkg_main;
|
||||
}
|
||||
|
||||
public function get room_bkg() : DisplayLayer
|
||||
{
|
||||
return this._layer_room_bkg;
|
||||
}
|
||||
|
||||
public function get room_fg() : DisplayLayer
|
||||
{
|
||||
return this._layer_room_fg;
|
||||
}
|
||||
|
||||
public function get room_super_fg() : DisplayLayer
|
||||
{
|
||||
return this._layer_room_super_fg;
|
||||
}
|
||||
|
||||
public function get room_avatars() : SortLayer
|
||||
{
|
||||
return this._layer_room_avatars;
|
||||
}
|
||||
|
||||
public function get room_chat() : DisplayLayer
|
||||
{
|
||||
return this._layer_room_chat;
|
||||
}
|
||||
|
||||
public function get flying_avatars() : SortLayer
|
||||
{
|
||||
return this._layer_flying_avatars;
|
||||
}
|
||||
|
||||
public function get room_orbs() : DisplayLayer
|
||||
{
|
||||
return this._layer_room_orbs;
|
||||
}
|
||||
|
||||
public function get layer_debug() : DisplayLayer
|
||||
{
|
||||
return this._layer_debug;
|
||||
}
|
||||
|
||||
public function get layer_worldGame() : DisplayLayer
|
||||
{
|
||||
return this._layer_worldGame;
|
||||
}
|
||||
|
||||
public function get preview_room_avatar() : SortLayer
|
||||
{
|
||||
return this._layer_room_preview_avatar;
|
||||
}
|
||||
|
||||
public function get preview_room_flying_avatar() : SortLayer
|
||||
{
|
||||
return this._layer_room_preview_flying_avatar;
|
||||
}
|
||||
|
||||
public function get debugShape() : Shape
|
||||
{
|
||||
return this._debugShape;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package room
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class RoomEvent extends Event
|
||||
{
|
||||
|
||||
public static const LOAD_SFX:String = "RoomEventLoadSfx";
|
||||
|
||||
public static const PLAY_SFX:String = "RoomEventPlaySfx";
|
||||
|
||||
public static const PLAY_SWFSFX:String = "RoomEventPlaySwfSfx";
|
||||
|
||||
public static const PLAY_SWFSFXBYCLASS:String = "RoomEventPlaySwfSfxByClass";
|
||||
|
||||
public static const ATTACH_EMOTE:String = "RoomEventAttachEmote";
|
||||
|
||||
private var _secondaryType:String;
|
||||
|
||||
private var _tertiaryType:String;
|
||||
|
||||
private var _persistent:Boolean;
|
||||
|
||||
public function RoomEvent(type:String, secondaryType:String = "", tertiaryType:String = "", persistent:Boolean = false)
|
||||
{
|
||||
super(type,true,false);
|
||||
this._secondaryType = secondaryType;
|
||||
this._tertiaryType = tertiaryType;
|
||||
this._persistent = persistent;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new RoomEvent(type);
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return formatToString("RoomEvent",type,this._secondaryType,this._tertiaryType,this._persistent);
|
||||
}
|
||||
|
||||
public function get secondaryType() : String
|
||||
{
|
||||
return this._secondaryType;
|
||||
}
|
||||
|
||||
public function get tertiaryType() : String
|
||||
{
|
||||
return this._tertiaryType;
|
||||
}
|
||||
|
||||
public function get persistent() : Boolean
|
||||
{
|
||||
return this._persistent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,493 @@
|
||||
package room
|
||||
{
|
||||
import avatar.AvatarManager;
|
||||
import com.baseoneonline.astar.AStar;
|
||||
import com.baseoneonline.astar.Graph;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.ByteArray;
|
||||
import gui.GuiManager;
|
||||
|
||||
public class RoomGrid implements Graph
|
||||
{
|
||||
|
||||
public static const GRID_CELL_OPEN:uint = 0;
|
||||
|
||||
public static const GRID_CELL_WALL:uint = 1;
|
||||
|
||||
public static const GRID_CELL_AIR:uint = 2;
|
||||
|
||||
public static const GRID_CELL_PHANTOM:uint = 3;
|
||||
|
||||
private static const COST_DIAG:Number = Math.sqrt(2);
|
||||
|
||||
private var GRID_DEPTH_LIMIT:uint = 128;
|
||||
|
||||
private var startPos:Object;
|
||||
|
||||
private var _grid:Object;
|
||||
|
||||
private var _astar:AStar;
|
||||
|
||||
public function RoomGrid()
|
||||
{
|
||||
super();
|
||||
this._astar = new AStar();
|
||||
}
|
||||
|
||||
public function setGridDepth(depth:uint) : void
|
||||
{
|
||||
this.GRID_DEPTH_LIMIT = depth;
|
||||
}
|
||||
|
||||
public function setGrid(grid:Object) : void
|
||||
{
|
||||
var pos:int = 0;
|
||||
var packed:ByteArray = null;
|
||||
var g:Vector.<uint> = null;
|
||||
var i:int = 0;
|
||||
var count:uint = 0;
|
||||
var type:uint = 0;
|
||||
var j:int = 0;
|
||||
if(grid.hasOwnProperty("packedGrid"))
|
||||
{
|
||||
packed = grid.packedGrid;
|
||||
packed.position = 0;
|
||||
g = new Vector.<uint>(grid.height * grid.width);
|
||||
for(i = 0; i < packed.length / 2; i++)
|
||||
{
|
||||
count = packed.readUnsignedShort();
|
||||
type = uint(count >> 14);
|
||||
if(GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
if(Boolean(type & 1 << 1) && Boolean(AvatarManager.playerAvatarWorldView) && !AvatarManager.playerAvatarWorldView.isActivePetGroundPet())
|
||||
{
|
||||
type = 0;
|
||||
}
|
||||
}
|
||||
else if(Boolean(AvatarManager.playerAvatar.enviroTypeFlag & 1 << Utility.ENVIRO_AIR))
|
||||
{
|
||||
if((type & 1 << 1) == 0)
|
||||
{
|
||||
type = 0;
|
||||
}
|
||||
}
|
||||
else if(Boolean(AvatarManager.playerAvatar.enviroTypeFlag & 1 << Utility.ENVIRO_LAND))
|
||||
{
|
||||
if((type & 1 << 0) == 0)
|
||||
{
|
||||
type = 0;
|
||||
}
|
||||
}
|
||||
count &= 16383;
|
||||
for(j = 0; j < count; j++)
|
||||
{
|
||||
g[pos++] = type;
|
||||
}
|
||||
}
|
||||
grid.grid = g;
|
||||
}
|
||||
this._grid = grid;
|
||||
this._astar.setGraph(this);
|
||||
}
|
||||
|
||||
public function get hasReachedGoal() : Boolean
|
||||
{
|
||||
return this._astar.hasReachedGoal();
|
||||
}
|
||||
|
||||
public function enableVolume(name:String, bEnable:Boolean = true) : void
|
||||
{
|
||||
var d:Array = null;
|
||||
var i:int = 0;
|
||||
var dv:Object = null;
|
||||
var y:int = 0;
|
||||
var w:int = 0;
|
||||
var pos:int = 0;
|
||||
var c:int = 0;
|
||||
var count:uint = 0;
|
||||
var type:uint = 0;
|
||||
var j:int = 0;
|
||||
if(this._grid.hasOwnProperty("dynamicVolumes"))
|
||||
{
|
||||
for(d = this._grid.dynamicVolumes; i < d.length; )
|
||||
{
|
||||
dv = d[i];
|
||||
if(dv.name == name)
|
||||
{
|
||||
dv.packedBlock.position = 0;
|
||||
y = int(dv.y);
|
||||
pos = dv.x + dv.y * this._grid.width;
|
||||
for(c = 0; c < dv.packedBlock.length / 2; c++)
|
||||
{
|
||||
count = uint(dv.packedBlock.readUnsignedShort());
|
||||
type = uint(count >> 14);
|
||||
count &= 16383;
|
||||
for(j = 0; j < count; j++)
|
||||
{
|
||||
if(type > 0)
|
||||
{
|
||||
this._grid.grid[pos] = bEnable ? type : 0;
|
||||
}
|
||||
pos++;
|
||||
w++;
|
||||
if(w == dv.width)
|
||||
{
|
||||
w = 0;
|
||||
pos += this._grid.width - dv.width;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getCellIndex(x:Number, y:Number) : int
|
||||
{
|
||||
x -= this._grid.min.x;
|
||||
y -= this._grid.min.y;
|
||||
x /= this._grid.r2;
|
||||
y /= this._grid.r2;
|
||||
if(x < 0)
|
||||
{
|
||||
x = 0;
|
||||
}
|
||||
if(x >= this._grid.width)
|
||||
{
|
||||
x = this._grid.width - 1;
|
||||
}
|
||||
if(y < 0)
|
||||
{
|
||||
y = 0;
|
||||
}
|
||||
if(y >= this._grid.height)
|
||||
{
|
||||
y = this._grid.height - 1;
|
||||
}
|
||||
return int(int(x) + int(y) * this._grid.width);
|
||||
}
|
||||
|
||||
public function convertWorldPosToGrid(x:Number, y:Number) : Object
|
||||
{
|
||||
x -= this._grid.min.x;
|
||||
y -= this._grid.min.y;
|
||||
x /= this._grid.r2;
|
||||
y /= this._grid.r2;
|
||||
var bInBounds:Boolean = true;
|
||||
if(x < 0 || x >= this._grid.width || y < 0 || y >= this._grid.height)
|
||||
{
|
||||
bInBounds = false;
|
||||
}
|
||||
return {
|
||||
"x":int(x),
|
||||
"y":int(y),
|
||||
"bInBounds":bInBounds
|
||||
};
|
||||
}
|
||||
|
||||
public function convertCellToCoords(i:int) : Object
|
||||
{
|
||||
var y:Number = int(i / this._grid.width);
|
||||
var x:Number = Math.abs(i % this._grid.width);
|
||||
return {
|
||||
"x":x,
|
||||
"y":y
|
||||
};
|
||||
}
|
||||
|
||||
public function getCellIndexToWorldPos(i:int) : Object
|
||||
{
|
||||
var y:Number = int(i / this._grid.width);
|
||||
var x:Number = i - y * this._grid.width;
|
||||
x *= this._grid.r2;
|
||||
y *= this._grid.r2;
|
||||
x += this._grid.min.x + this._grid.r;
|
||||
y += this._grid.min.y + this._grid.r;
|
||||
return {
|
||||
"x":x,
|
||||
"y":y
|
||||
};
|
||||
}
|
||||
|
||||
public function convertGridPosToWorld(x:int, y:int) : Object
|
||||
{
|
||||
var xp:Number = x * this._grid.r2 + this._grid.min.x + this._grid.r;
|
||||
var yp:Number = y * this._grid.r2 + this._grid.min.y + this._grid.r;
|
||||
return {
|
||||
"x":xp,
|
||||
"y":yp
|
||||
};
|
||||
}
|
||||
|
||||
public function testGridCell(x:int, y:int) : uint
|
||||
{
|
||||
if(x >= 0 && x < this._grid.width && y >= 0 && y < this._grid.height)
|
||||
{
|
||||
return this._grid.grid[y * this._grid.width + x];
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function findPath(start:Point, end:Point) : Vector.<int>
|
||||
{
|
||||
if(!this._grid)
|
||||
{
|
||||
return new Vector.<int>();
|
||||
}
|
||||
return this._astar.solve(this.getCellIndex(start.x,start.y),this.getCellIndex(end.x,end.y));
|
||||
}
|
||||
|
||||
public function findPathOptimized(start:Point, end:Point) : Vector.<int>
|
||||
{
|
||||
var newDir:int = 0;
|
||||
if(!this._grid)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var si:int = this.getCellIndex(start.x,start.y);
|
||||
var ei:int = this.getCellIndex(end.x,end.y);
|
||||
if(si < 0 || ei < 0 || si > this.size() || ei > this.size())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var p:Vector.<int> = this._astar.solve(si,ei);
|
||||
var a:Vector.<int> = new Vector.<int>();
|
||||
if(p.length == 1)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
var dir:int = this.getCellDir(p[0],p[1]);
|
||||
var len:int = int(p.length);
|
||||
var lastAdded:int = 0;
|
||||
for(var i:int = 1; i < len; i++)
|
||||
{
|
||||
newDir = this.getCellDir(p[i - 1],p[i]);
|
||||
if(dir != newDir)
|
||||
{
|
||||
dir = newDir;
|
||||
if(lastAdded != i - 1)
|
||||
{
|
||||
a.push(p[i]);
|
||||
lastAdded = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(a.length == 0 || Boolean(a.length) && Boolean(a[a.length - 1] != p[p.length - 1]))
|
||||
{
|
||||
a.push(p[p.length - 1]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private function getCellDir(c1:int, c2:int) : int
|
||||
{
|
||||
var d:int = -1;
|
||||
var w:int = int(this._grid.width);
|
||||
if(c1 - w == c2)
|
||||
{
|
||||
d = 0;
|
||||
}
|
||||
else if(c1 - w + 1 == c2)
|
||||
{
|
||||
d = 1;
|
||||
}
|
||||
else if(c1 + 1 == c2)
|
||||
{
|
||||
d = 2;
|
||||
}
|
||||
else if(c1 + w + 1 == c2)
|
||||
{
|
||||
d = 3;
|
||||
}
|
||||
else if(c1 + w == c2)
|
||||
{
|
||||
d = 4;
|
||||
}
|
||||
else if(c1 + w - 1 == c2)
|
||||
{
|
||||
d = 5;
|
||||
}
|
||||
else if(c1 - 1 == c2)
|
||||
{
|
||||
d = 6;
|
||||
}
|
||||
else if(c1 - w - 1 == c2)
|
||||
{
|
||||
d = 7;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
public function setStartGridPos(i:int) : void
|
||||
{
|
||||
this.startPos = this.convertCellToCoords(i);
|
||||
}
|
||||
|
||||
public function getNeighbors(i:int, neighbors:Vector.<int>) : Vector.<int>
|
||||
{
|
||||
var c:int = 0;
|
||||
var pos:Object = this.convertCellToCoords(i);
|
||||
var x:int = int(pos.x);
|
||||
var y:int = int(pos.y);
|
||||
var w:int = int(this._grid.width);
|
||||
var h:int = int(this._grid.height);
|
||||
var wIsValid:Boolean = Math.abs(pos.x - 1 - this.startPos.x) < this.GRID_DEPTH_LIMIT;
|
||||
var eIsValid:Boolean = Math.abs(pos.x + 1 - this.startPos.x) < this.GRID_DEPTH_LIMIT;
|
||||
var nIsValid:Boolean = Math.abs(pos.y - 1 - this.startPos.y) < this.GRID_DEPTH_LIMIT;
|
||||
var sIsValid:Boolean = Math.abs(pos.y + 1 - this.startPos.y) < this.GRID_DEPTH_LIMIT;
|
||||
neighbors.length = 0;
|
||||
if(x > 0)
|
||||
{
|
||||
c = i - 1;
|
||||
if(!this._grid.grid[c] && wIsValid)
|
||||
{
|
||||
neighbors.push(c);
|
||||
}
|
||||
}
|
||||
if(y > 0)
|
||||
{
|
||||
c = i - w;
|
||||
if(!this._grid.grid[c] && nIsValid)
|
||||
{
|
||||
neighbors.push(c);
|
||||
}
|
||||
}
|
||||
if(x < w - 1)
|
||||
{
|
||||
c = i + 1;
|
||||
if(!this._grid.grid[c] && eIsValid)
|
||||
{
|
||||
neighbors.push(c);
|
||||
}
|
||||
}
|
||||
if(y < h - 1)
|
||||
{
|
||||
c = i + w;
|
||||
if(!this._grid.grid[c] && sIsValid)
|
||||
{
|
||||
neighbors.push(c);
|
||||
}
|
||||
}
|
||||
if(x > 0 && y > 0)
|
||||
{
|
||||
c = i - 1 - w;
|
||||
if(!this._grid.grid[c] && !this._grid.grid[i - 1] && !this._grid.grid[i - w] && nIsValid && wIsValid)
|
||||
{
|
||||
neighbors.push(c);
|
||||
}
|
||||
}
|
||||
if(x < w - 1 && y > 0)
|
||||
{
|
||||
c = i + 1 - w;
|
||||
if(!this._grid.grid[c] && !this._grid.grid[i + 1] && !this._grid.grid[i - w] && nIsValid && eIsValid)
|
||||
{
|
||||
neighbors.push(c);
|
||||
}
|
||||
}
|
||||
if(x > 0 && y < h - 1)
|
||||
{
|
||||
c = i - 1 + w;
|
||||
if(!this._grid.grid[c] && !this._grid.grid[i - 1] && !this._grid.grid[i + w] && sIsValid && wIsValid)
|
||||
{
|
||||
neighbors.push(c);
|
||||
}
|
||||
}
|
||||
if(x < w - 1 && y < h - 1)
|
||||
{
|
||||
c = i + 1 + w;
|
||||
if(!this._grid.grid[c] && !this._grid.grid[i + 1] && !this._grid.grid[i + w] && sIsValid && eIsValid)
|
||||
{
|
||||
neighbors.push(c);
|
||||
}
|
||||
}
|
||||
return neighbors;
|
||||
}
|
||||
|
||||
public function distance(a:int, b:int) : Number
|
||||
{
|
||||
var n1:Object = this.getCellIndexToWorldPos(a);
|
||||
var n2:Object = this.getCellIndexToWorldPos(b);
|
||||
var h_diag:Number = Math.min(Math.abs(n1.x - n2.x),Math.abs(n1.y - n2.y));
|
||||
var h_orth:Number = Math.abs(n1.x - n2.x) + Math.abs(n1.y - n2.y);
|
||||
return COST_DIAG * h_diag + h_orth - 2 * h_diag;
|
||||
}
|
||||
|
||||
public function size() : int
|
||||
{
|
||||
if(this._grid == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return this._grid.width * this._grid.height;
|
||||
}
|
||||
|
||||
public function findClosestOpenGridCell(xs:Number, ys:Number) : Object
|
||||
{
|
||||
var ci:int = 0;
|
||||
var pos:Object = this.convertWorldPosToGrid(xs,ys);
|
||||
var x:int = int(pos.x);
|
||||
var y:int = int(pos.y);
|
||||
var w:int = int(this._grid.width);
|
||||
var h:int = int(this._grid.height);
|
||||
var step:int = 3;
|
||||
var stepMax:int = 20;
|
||||
while(step < stepMax)
|
||||
{
|
||||
pos = this.scanBox(x,y,step);
|
||||
if(Boolean(pos))
|
||||
{
|
||||
break;
|
||||
}
|
||||
step += 2;
|
||||
x--;
|
||||
y--;
|
||||
}
|
||||
if(Boolean(pos))
|
||||
{
|
||||
pos = this.convertGridPosToWorld(pos.x,pos.y);
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
private function scanBox(x:int, y:int, size:int) : Object
|
||||
{
|
||||
var dir:int = 0;
|
||||
var count:int = 0;
|
||||
size--;
|
||||
x++;
|
||||
while(dir < 4)
|
||||
{
|
||||
if(!this.testGridCell(x,y))
|
||||
{
|
||||
return {
|
||||
"x":x,
|
||||
"y":y
|
||||
};
|
||||
}
|
||||
count++;
|
||||
if(count == size)
|
||||
{
|
||||
count = 0;
|
||||
dir++;
|
||||
}
|
||||
switch(dir)
|
||||
{
|
||||
case 0:
|
||||
x++;
|
||||
break;
|
||||
case 1:
|
||||
y++;
|
||||
break;
|
||||
case 2:
|
||||
x--;
|
||||
break;
|
||||
case 3:
|
||||
y--;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,52 @@
|
||||
package room
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.Event;
|
||||
|
||||
public class RoomObject
|
||||
{
|
||||
|
||||
protected var _mc:MovieClip;
|
||||
|
||||
protected var _dir:int;
|
||||
|
||||
protected var _bHold:Boolean;
|
||||
|
||||
public function RoomObject(mc:MovieClip)
|
||||
{
|
||||
super();
|
||||
this._dir = 0;
|
||||
this._mc = mc;
|
||||
mc.addEventListener(Event.ENTER_FRAME,this.onEnterFrame);
|
||||
}
|
||||
|
||||
public function get hold() : Boolean
|
||||
{
|
||||
return this._bHold;
|
||||
}
|
||||
|
||||
public function mouseDown(f:Boolean) : void
|
||||
{
|
||||
this._bHold = f;
|
||||
}
|
||||
|
||||
public function release() : void
|
||||
{
|
||||
if(Boolean(this._mc))
|
||||
{
|
||||
this._mc.removeEventListener(Event.ENTER_FRAME,this.onEnterFrame);
|
||||
this._mc = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function setDir(d:int) : void
|
||||
{
|
||||
this._dir = d;
|
||||
}
|
||||
|
||||
protected function onEnterFrame(e:Event) : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package room
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.Event;
|
||||
|
||||
public class RoomObject_ForwardReverseHold extends RoomObject
|
||||
{
|
||||
|
||||
public function RoomObject_ForwardReverseHold(mc:MovieClip)
|
||||
{
|
||||
super(mc);
|
||||
mc.gotoAndStop(1);
|
||||
}
|
||||
|
||||
override public function mouseDown(f:Boolean) : void
|
||||
{
|
||||
if(f && _bHold == false && _mc.hasOwnProperty("mouseDown"))
|
||||
{
|
||||
_mc.mouseDown();
|
||||
}
|
||||
_bHold = f;
|
||||
}
|
||||
|
||||
override protected function onEnterFrame(e:Event) : void
|
||||
{
|
||||
var f:int = _mc.currentFrame;
|
||||
if(_dir == 1)
|
||||
{
|
||||
f++;
|
||||
if(f <= _mc.totalFrames)
|
||||
{
|
||||
_mc.gotoAndStop(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_dir = 0;
|
||||
}
|
||||
}
|
||||
else if(_dir == -1)
|
||||
{
|
||||
f--;
|
||||
if(f > 0)
|
||||
{
|
||||
_mc.gotoAndStop(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_dir = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package room
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
|
||||
public class RoomObject_GemPickup extends RoomObject
|
||||
{
|
||||
|
||||
public function RoomObject_GemPickup(mc:MovieClip)
|
||||
{
|
||||
super(mc);
|
||||
}
|
||||
|
||||
override public function mouseDown(f:Boolean) : void
|
||||
{
|
||||
if(f && _bHold == false)
|
||||
{
|
||||
_mc.visible = false;
|
||||
_bHold = true;
|
||||
release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package room
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.Event;
|
||||
|
||||
public class RoomObject_IdleActive extends RoomObject
|
||||
{
|
||||
|
||||
public function RoomObject_IdleActive(mc:MovieClip)
|
||||
{
|
||||
super(mc);
|
||||
}
|
||||
|
||||
override public function mouseDown(f:Boolean) : void
|
||||
{
|
||||
if(f && _bHold == false)
|
||||
{
|
||||
_mc.gotoAndPlay("active");
|
||||
_bHold = true;
|
||||
}
|
||||
}
|
||||
|
||||
override protected function onEnterFrame(e:Event) : void
|
||||
{
|
||||
if(_bHold && _mc.currentLabel == "idle")
|
||||
{
|
||||
_bHold = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package room
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.Event;
|
||||
|
||||
public class RoomObject_RandomClick extends RoomObject
|
||||
{
|
||||
|
||||
private var _frameCountdown:int;
|
||||
|
||||
public function RoomObject_RandomClick(mc:MovieClip)
|
||||
{
|
||||
super(mc);
|
||||
mc.stop();
|
||||
}
|
||||
|
||||
override public function mouseDown(f:Boolean) : void
|
||||
{
|
||||
if(_bHold == false && f == true)
|
||||
{
|
||||
this._frameCountdown = 5 + int(Math.random() * _mc.totalFrames) / 2;
|
||||
_bHold = true;
|
||||
}
|
||||
}
|
||||
|
||||
override protected function onEnterFrame(e:Event) : void
|
||||
{
|
||||
if(_bHold)
|
||||
{
|
||||
if(_mc.currentFrame == _mc.totalFrames)
|
||||
{
|
||||
_mc.gotoAndStop(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mc.nextFrame();
|
||||
}
|
||||
if(this._frameCountdown == 0)
|
||||
{
|
||||
_bHold = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
--this._frameCountdown;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package room
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
|
||||
public class RoomObject_SocialTrigger extends RoomObject
|
||||
{
|
||||
|
||||
private var _currentStage:int;
|
||||
|
||||
private var _stages:Array;
|
||||
|
||||
private var _totalCount:int;
|
||||
|
||||
public function RoomObject_SocialTrigger(mc:MovieClip)
|
||||
{
|
||||
super(mc);
|
||||
this._stages = mc.stages;
|
||||
this.clearCount();
|
||||
this.update();
|
||||
}
|
||||
|
||||
public function clearCount() : void
|
||||
{
|
||||
this._totalCount = 0;
|
||||
}
|
||||
|
||||
public function incCount() : void
|
||||
{
|
||||
++this._totalCount;
|
||||
}
|
||||
|
||||
public function update() : void
|
||||
{
|
||||
var i:int = 0;
|
||||
for(var newStage:int = 0; i < this._stages.length; )
|
||||
{
|
||||
if(this._totalCount < this._stages[i].total)
|
||||
{
|
||||
break;
|
||||
}
|
||||
newStage = i;
|
||||
i++;
|
||||
}
|
||||
if(this._currentStage != newStage)
|
||||
{
|
||||
this._currentStage = newStage;
|
||||
_mc.gotoAndPlay(this._stages[this._currentStage].label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,452 @@
|
||||
package room
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import avatar.AvatarManager;
|
||||
import com.sbi.analytics.SBTracker;
|
||||
import com.sbi.client.SFEvent;
|
||||
import com.sbi.client.SFRoom;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import com.sbi.popup.SBStandardPopup;
|
||||
import com.sbi.popup.SBYesNoPopup;
|
||||
import den.DenXtCommManager;
|
||||
import game.MinigameManager;
|
||||
import gamePlayFlow.GamePlay;
|
||||
import gui.BuddyCard;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import gui.WelcomeToCarnival;
|
||||
import localization.LocalizationManager;
|
||||
import pet.PetManager;
|
||||
import quest.QuestXtCommManager;
|
||||
|
||||
public class RoomXtCommManager
|
||||
{
|
||||
|
||||
public static var roomCountResponseCallback:Function;
|
||||
|
||||
public static var isSwitching:Boolean;
|
||||
|
||||
public static var _joinRoomName:String;
|
||||
|
||||
public static var _loadingNewRoom:Boolean;
|
||||
|
||||
private static var _denJoinPending:Boolean;
|
||||
|
||||
private static var _waitForLangPack:Boolean;
|
||||
|
||||
private static var _savedRPData:Object;
|
||||
|
||||
private static var _roomMgr:RoomManagerWorld;
|
||||
|
||||
private static var _rfCallback:Function;
|
||||
|
||||
public static var _welcomePopup:WelcomeToCarnival;
|
||||
|
||||
public static const RT_PARAM_GET_SHARD_FROM_DEN:int = -1;
|
||||
|
||||
public static const RT_PARAM_NEW_REGISTRANT_EXPERIENCE_REDIRECT:int = -2;
|
||||
|
||||
public function RoomXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
_denJoinPending = false;
|
||||
_waitForLangPack = false;
|
||||
_savedRPData = null;
|
||||
_roomMgr = RoomManagerWorld.instance;
|
||||
XtReplyDemuxer.addModule(handleXtReply,"r");
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
XtReplyDemuxer.removeModule(handleXtReply);
|
||||
roomCountResponseCallback = null;
|
||||
}
|
||||
|
||||
public static function sendRoomCountRequest(userNames:Array) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("rc",userNames,true,false,false);
|
||||
}
|
||||
|
||||
public static function sendMoreShardRequest() : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("rm",[]);
|
||||
}
|
||||
|
||||
public static function sendRoomFFMRequest(rfCallback:Function) : void
|
||||
{
|
||||
_rfCallback = rfCallback;
|
||||
gMainFrame.server.setXtObject_Str("rf",[]);
|
||||
}
|
||||
|
||||
public static function sendNonDenRoomJoinRequest(rjNameOrId:String) : void
|
||||
{
|
||||
sendRoomJoinRequestFull(rjNameOrId);
|
||||
}
|
||||
|
||||
public static function set waitForLangPack(setWait:Boolean) : void
|
||||
{
|
||||
_waitForLangPack = setWait;
|
||||
}
|
||||
|
||||
public static function sendRoomJoinRequest(rjNameOrId:String, portalInvId:int = -1, isFromMinigame:Boolean = false, forceInvisMode:Boolean = false, confirmLanguageChange:Boolean = true) : void
|
||||
{
|
||||
if(rjNameOrId.slice(0,3) == "den" && !isFromMinigame)
|
||||
{
|
||||
DenXtCommManager.requestDenJoinFull(rjNameOrId,portalInvId,forceInvisMode,confirmLanguageChange);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendRoomJoinRequestFull(rjNameOrId,forceInvisMode,confirmLanguageChange);
|
||||
}
|
||||
}
|
||||
|
||||
private static function sendRoomJoinRequestFull(rjNameOrId:String, forceInvisMode:Boolean = false, confirmLanguageChange:Boolean = true) : void
|
||||
{
|
||||
if(_loadingNewRoom)
|
||||
{
|
||||
DebugUtility.debugTrace("IGNORING rj request to room=" + rjNameOrId + " because user is already joining a new room!");
|
||||
return;
|
||||
}
|
||||
if(isSwitching)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
return;
|
||||
}
|
||||
if(Boolean(gMainFrame.server.getCurrentRoom()))
|
||||
{
|
||||
if(rjNameOrId == gMainFrame.server.getCurrentRoomName())
|
||||
{
|
||||
trace("WARNING: User is already in this room!");
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
AvatarManager.joiningNewRoom = true;
|
||||
_loadingNewRoom = true;
|
||||
var atIdx:int = rjNameOrId.indexOf("@");
|
||||
if(atIdx < 0)
|
||||
{
|
||||
_joinRoomName = rjNameOrId;
|
||||
}
|
||||
else
|
||||
{
|
||||
_joinRoomName = rjNameOrId.substring(0,atIdx);
|
||||
}
|
||||
if(RoomManagerWorld.instance.haveHadLastGoodRoomName())
|
||||
{
|
||||
SBTracker.trackPageview("/game/play/loading/changeRooms");
|
||||
}
|
||||
var confirmLanguageChangeString:String = confirmLanguageChange ? "1" : "0";
|
||||
var forceInvisNow:Boolean = forceInvisMode || _roomMgr.forceInvisMode;
|
||||
if(!forceInvisNow)
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("rj",[rjNameOrId,confirmLanguageChangeString]);
|
||||
}
|
||||
else
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("rj",[rjNameOrId,confirmLanguageChangeString,"1"]);
|
||||
_roomMgr.forceInvisMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendRoomLeaveRequest(roomId:int, useSubRoom:Boolean = false) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("rl",[roomId],true,useSubRoom);
|
||||
gMainFrame.server.handleSubRoomExit();
|
||||
}
|
||||
|
||||
public static function denJoinRequested(avIdOrDenRoomName:String) : void
|
||||
{
|
||||
_loadingNewRoom = true;
|
||||
_joinRoomName = avIdOrDenRoomName;
|
||||
_denJoinPending = true;
|
||||
}
|
||||
|
||||
public static function get loadingNewRoom() : Boolean
|
||||
{
|
||||
return _loadingNewRoom;
|
||||
}
|
||||
|
||||
public static function set loadingNewRoom(value:Boolean) : void
|
||||
{
|
||||
_loadingNewRoom = value;
|
||||
}
|
||||
|
||||
public static function startRoomLoadIfReady() : void
|
||||
{
|
||||
_waitForLangPack = false;
|
||||
if(Boolean(_savedRPData))
|
||||
{
|
||||
roomPropertiesResponse(_savedRPData);
|
||||
_savedRPData = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleXtReply(evt:SFEvent) : void
|
||||
{
|
||||
var data:Object = evt.obj;
|
||||
switch(data[0])
|
||||
{
|
||||
case "rj":
|
||||
roomJoinResponse(data);
|
||||
break;
|
||||
case "rp":
|
||||
roomPropertiesResponse(data);
|
||||
break;
|
||||
case "rc":
|
||||
roomCountResponse(data);
|
||||
break;
|
||||
case "rf":
|
||||
roomFFMResponse(data);
|
||||
break;
|
||||
case "rl":
|
||||
roomListResponse(data);
|
||||
break;
|
||||
case "rm":
|
||||
roomMoreResponse(data);
|
||||
break;
|
||||
default:
|
||||
throw new Error("RoomXtCommManager: Received illegal cmd: " + data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static function roomJoinResponse(data:Object) : void
|
||||
{
|
||||
var s:SFRoom = null;
|
||||
var displayName:String = null;
|
||||
var displayNameId:int = 0;
|
||||
var roomLanguageId:int = 0;
|
||||
var joinedShardId:int = 0;
|
||||
var msg:String = null;
|
||||
var newNode:String = null;
|
||||
var asrShardId:int = 0;
|
||||
var i:int = 2;
|
||||
if(data[i++] == "1")
|
||||
{
|
||||
s = new SFRoom();
|
||||
s.name = data[i++];
|
||||
s.id = int(data[i++]);
|
||||
s.users = int(data[i++]);
|
||||
s.maxUsers = int(data[i++]);
|
||||
s.spectators = int(data[i++]);
|
||||
s.maxSpectators = int(data[i++]);
|
||||
s.isPrivate = data[i++] == "1";
|
||||
s.isGame = data[i++] == "1";
|
||||
s.isLimbo = data[i++] == "1";
|
||||
s.isTemp = data[i++] == "1";
|
||||
displayName = data[i++];
|
||||
displayNameId = int(data[i++]);
|
||||
gMainFrame.userInfo.myPerUserAvId = int(data[i++]);
|
||||
PetManager.myActivePetInvId = int(data[i++]);
|
||||
roomLanguageId = int(data[i++]);
|
||||
if(data.hasOwnProperty(i))
|
||||
{
|
||||
joinedShardId = int(data[i++]);
|
||||
_roomMgr.shardId = joinedShardId;
|
||||
}
|
||||
if(roomLanguageId != LocalizationManager.currentLanguage && !MinigameManager.inInRoomGame())
|
||||
{
|
||||
LocalizationXtCommManager.requestLocalizationPack(roomLanguageId);
|
||||
}
|
||||
gMainFrame.server.handleRoomJoin(s);
|
||||
_roomMgr.forceInvisMode = false;
|
||||
if(!s.isGame || s.name.indexOf("den") == 0 || s.name.indexOf("party") == 0 || s.name.indexOf("staging") == 0)
|
||||
{
|
||||
GuiManager.setRoomNameDisplay(displayName,displayNameId);
|
||||
}
|
||||
if(s.name.indexOf("venue_carnival") != -1)
|
||||
{
|
||||
if(gMainFrame.userInfo.userVarCache.getUserVarValueById(343) < 1)
|
||||
{
|
||||
_welcomePopup = new WelcomeToCarnival();
|
||||
_welcomePopup.init();
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
AchievementXtCommManager.requestSetUserVar(343,1);
|
||||
}
|
||||
}
|
||||
else if(s.name.indexOf("room_diamonds") != -1)
|
||||
{
|
||||
if(gMainFrame.userInfo.userVarCache.getUserVarValueById(368) < 1)
|
||||
{
|
||||
GuiManager.openDiamondShopInfo();
|
||||
AchievementXtCommManager.requestSetUserVar(368,1);
|
||||
}
|
||||
}
|
||||
delete gMainFrame.clientInfo.autoStartRoom;
|
||||
QuestXtCommManager.roomJoined(s.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = data[i++];
|
||||
if(msg == "N")
|
||||
{
|
||||
newNode = data[i++];
|
||||
if(newNode == "null")
|
||||
{
|
||||
new SBStandardPopup(LoadProgress.loadLayer,LocalizationManager.translateIdOnly(14834),false);
|
||||
AvatarManager.joiningNewRoom = false;
|
||||
_denJoinPending = false;
|
||||
return;
|
||||
}
|
||||
gMainFrame.userInfo.myPerUserAvId = int(data[i++]);
|
||||
if(_denJoinPending)
|
||||
{
|
||||
gMainFrame.clientInfo.autoStartRoom = _joinRoomName;
|
||||
gMainFrame.clientInfo.autoStartRoomShardId = RT_PARAM_GET_SHARD_FROM_DEN;
|
||||
DebugUtility.debugTrace("using autoStartRoom to prep resend join request after switching server nodes - room:" + _joinRoomName + " shardId:" + gMainFrame.clientInfo.autoStartRoomShardId);
|
||||
if(!gMainFrame.switchServersIfNeeded(newNode))
|
||||
{
|
||||
throw new Error("got join room response saying to switch server nodes, but was already on that node!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_joinRoomName.indexOf("#") < 0)
|
||||
{
|
||||
throw new Error("join room request for sfs room:" + _joinRoomName + " somehow is on another server node:" + newNode + " (current node:" + gMainFrame.server.serverIp + ")?!");
|
||||
}
|
||||
gMainFrame.clientInfo.autoStartRoom = _joinRoomName;
|
||||
asrShardId = int(_joinRoomName.substr(_joinRoomName.indexOf("#") + 1));
|
||||
if(asrShardId == -1)
|
||||
{
|
||||
asrShardId = RT_PARAM_NEW_REGISTRANT_EXPERIENCE_REDIRECT;
|
||||
}
|
||||
gMainFrame.clientInfo.autoStartRoomShardId = asrShardId;
|
||||
DebugUtility.debugTrace("using autoStartRoom to prep resend join request after switching server nodes - room:" + _joinRoomName + " shardId:" + gMainFrame.clientInfo.autoStartRoomShardId);
|
||||
if(!gMainFrame.switchServersIfNeeded(newNode))
|
||||
{
|
||||
new SBStandardPopup(LoadProgress.loadLayer,LocalizationManager.translateIdOnly(14835),false);
|
||||
AvatarManager.joiningNewRoom = false;
|
||||
_denJoinPending = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
_roomMgr.clearLastGoodRoomForServerSwitch();
|
||||
}
|
||||
else if(msg.indexOf("DJE") == 0)
|
||||
{
|
||||
if(msg.charAt(3) == "C")
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBYesNoPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14836),true,GuiManager.switchToOceanAnimal,false);
|
||||
}
|
||||
else if(msg.charAt(3) == "E")
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBYesNoPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14836),true,GuiManager.switchToOceanAnimal,true);
|
||||
}
|
||||
else if(msg.charAt(3) == "K")
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBYesNoPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14837),true,GuiManager.switchToOceanAnimal,false);
|
||||
}
|
||||
}
|
||||
else if(msg == "BSJ")
|
||||
{
|
||||
_loadingNewRoom = false;
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14838));
|
||||
}
|
||||
else if(msg == "SSJ")
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14839));
|
||||
}
|
||||
else if(msg == "CSJ")
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14840));
|
||||
}
|
||||
else if(msg == "QSJL")
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14841));
|
||||
}
|
||||
else if(msg == "BQSJ")
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14842));
|
||||
}
|
||||
else if(msg == "RQJF")
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14843));
|
||||
}
|
||||
else if(msg == "RQJF_NL")
|
||||
{
|
||||
_loadingNewRoom = false;
|
||||
if(!BuddyCard.joinBuddyInQuest())
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14843));
|
||||
}
|
||||
}
|
||||
else if(msg == "SQQJ")
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14844));
|
||||
}
|
||||
else if(msg != "LC")
|
||||
{
|
||||
gMainFrame.server.handleRoomJoinError(msg,data[i]);
|
||||
}
|
||||
_loadingNewRoom = false;
|
||||
}
|
||||
AvatarManager.joiningNewRoom = false;
|
||||
_denJoinPending = false;
|
||||
}
|
||||
|
||||
private static function roomPropertiesResponse(data:Object) : void
|
||||
{
|
||||
if(_waitForLangPack)
|
||||
{
|
||||
_savedRPData = data;
|
||||
return;
|
||||
}
|
||||
_roomMgr.loadRoom(data[2],int(data[3]),int(data[4]),int(data[5]),int(data[6]));
|
||||
AvatarManager.finishHandleAvatarCreate();
|
||||
}
|
||||
|
||||
private static function roomCountResponse(data:Object) : void
|
||||
{
|
||||
if(roomCountResponseCallback != null)
|
||||
{
|
||||
roomCountResponseCallback(data);
|
||||
}
|
||||
}
|
||||
|
||||
private static function roomMoreResponse(data:Object) : void
|
||||
{
|
||||
var statusId:int = 0;
|
||||
if(!isNaN(Number(data[2])))
|
||||
{
|
||||
statusId = int(data[2]);
|
||||
if(statusId <= 0)
|
||||
{
|
||||
new SBStandardPopup(LoadProgress.loadLayer,LocalizationManager.translateIdOnly(14847),false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
GamePlay(gMainFrame.gamePlay).showServerSelectorMore(data);
|
||||
}
|
||||
|
||||
private static function roomFFMResponse(data:Object) : void
|
||||
{
|
||||
if(data[2] == "1" && _rfCallback != null)
|
||||
{
|
||||
_rfCallback();
|
||||
}
|
||||
}
|
||||
|
||||
private static function roomListResponse(data:Object) : void
|
||||
{
|
||||
gMainFrame.server.setRoomList(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,564 @@
|
||||
package room
|
||||
{
|
||||
import com.sbi.loader.SceneLoader;
|
||||
import flash.display.MovieClip;
|
||||
import flash.geom.Point;
|
||||
|
||||
public class VolumeManager
|
||||
{
|
||||
|
||||
public static const VOLUMETYPE_NONE:int = 0;
|
||||
|
||||
public static const VOLUMETYPE_GAME:int = 1;
|
||||
|
||||
public static const VOLUMETYPE_DEN_VOLUME:int = 2;
|
||||
|
||||
public static const VOLUMETYPE_SPLASH:int = 3;
|
||||
|
||||
public static const VOLUMETYPE_STORE_PET:int = 4;
|
||||
|
||||
public static const VOLUMETYPE_SOCIAL_GROUP:int = 5;
|
||||
|
||||
public static const VOLUMETYPE_SOCIAL_EMOTICON:int = 6;
|
||||
|
||||
public static const VOLUMETYPE_GUI_ACTION:int = 7;
|
||||
|
||||
public static const VOLUMETYPE_RECYCLE_ACCESSORY:int = 8;
|
||||
|
||||
public static const VOLUMETYPE_RECYCLE_DEN_ITEM:int = 9;
|
||||
|
||||
public static const VOLUMETYPE_TRIGGER_WALKIN:int = 11;
|
||||
|
||||
public static const VOLUMETYPE_GENERIC_LIST:int = 12;
|
||||
|
||||
public static const VOLUMETYPE_CLICK_EMOTICON:int = 13;
|
||||
|
||||
public static const VOLUMETYPE_AIR:int = 14;
|
||||
|
||||
public static const VOLUMETYPE_DYNAMIC_COLLISION:int = 15;
|
||||
|
||||
public static const VOLUMETYPE_DYNAMIC_AIR:int = 16;
|
||||
|
||||
public static const VOLUMETYPE_DYNAMIC_PHANTOM_AIR:int = 17;
|
||||
|
||||
public static const VOLUMETYPE_PLANT:int = 18;
|
||||
|
||||
public static const VOLUMETYPE_STEALTH:int = 19;
|
||||
|
||||
public static const VOLUMETYPE_ADVENTURE_INTERACT:int = 20;
|
||||
|
||||
public static const VOLUMETYPE_DARKSOFT:int = 21;
|
||||
|
||||
public static const VOLUMETYPE_DARKHARD:int = 22;
|
||||
|
||||
public static const VOLUMETYPE_FALLINGPHANTOM:int = 23;
|
||||
|
||||
private var _scene:SceneLoader;
|
||||
|
||||
private var _volumes:Array;
|
||||
|
||||
private var _layers:Array;
|
||||
|
||||
private var _volumeActors:Array;
|
||||
|
||||
private var _roomObjs:Array;
|
||||
|
||||
private var _offset:Point;
|
||||
|
||||
private var _socialTriggersVolumes:Array;
|
||||
|
||||
private var _splashVolumes:Array;
|
||||
|
||||
public function VolumeManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function setScene(scene:SceneLoader, offset:Point) : void
|
||||
{
|
||||
var i:int = 0;
|
||||
var o:Object = null;
|
||||
this.release();
|
||||
this._socialTriggersVolumes = [];
|
||||
this._splashVolumes = [];
|
||||
this._roomObjs = [];
|
||||
this._volumeActors = [];
|
||||
this._scene = scene;
|
||||
this._offset = offset;
|
||||
this._volumes = scene.getActorList("ActorVolume");
|
||||
this._layers = this._scene.getActorList("ActorLayer");
|
||||
if(Boolean(this._volumes))
|
||||
{
|
||||
for(i = 0; i < this._volumes.length; i++)
|
||||
{
|
||||
o = this._volumes[i];
|
||||
this.newVolume(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function release() : void
|
||||
{
|
||||
var i:int = 0;
|
||||
var o:Object = null;
|
||||
var ro:* = undefined;
|
||||
if(Boolean(this._volumeActors))
|
||||
{
|
||||
for(i = 0; i < this._volumeActors.length; i++)
|
||||
{
|
||||
for each(ro in this._volumeActors[i].interactiveObjs)
|
||||
{
|
||||
ro.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Boolean(this._roomObjs))
|
||||
{
|
||||
for each(o in this._roomObjs)
|
||||
{
|
||||
o.release();
|
||||
}
|
||||
}
|
||||
this._socialTriggersVolumes = null;
|
||||
this._volumes = null;
|
||||
this._layers = null;
|
||||
this._splashVolumes = null;
|
||||
}
|
||||
|
||||
public function get hasSplashVolume() : Boolean
|
||||
{
|
||||
return Boolean(this._splashVolumes) && Boolean(this._splashVolumes.length);
|
||||
}
|
||||
|
||||
public function clearHold(bMouseDown:Boolean = true) : void
|
||||
{
|
||||
var ro:RoomObject = null;
|
||||
for each(ro in this._roomObjs)
|
||||
{
|
||||
if(bMouseDown)
|
||||
{
|
||||
ro.mouseDown(false);
|
||||
}
|
||||
if(!ro.hold)
|
||||
{
|
||||
ro.setDir(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testPointInVolume(p:Point, volume:Object) : Boolean
|
||||
{
|
||||
return this.pointInVolume(p,volume.v);
|
||||
}
|
||||
|
||||
public function testMouseVolumes(p:Point, bMouseDown:Boolean, checkVolumeUse:Function = null) : Object
|
||||
{
|
||||
var ret:Object = null;
|
||||
var i:int = 0;
|
||||
var j:int = 0;
|
||||
var o:Object = null;
|
||||
var ro:RoomObject = null;
|
||||
if(Boolean(this._volumeActors))
|
||||
{
|
||||
this.clearHold(bMouseDown);
|
||||
if(bMouseDown)
|
||||
{
|
||||
for(i = 0; i < this._volumeActors.length; i++)
|
||||
{
|
||||
o = this._volumeActors[i];
|
||||
if(this.isMouseVolume(o.type) && this.pointInVolume(p,o.v))
|
||||
{
|
||||
if(Boolean(o.interactiveObjs))
|
||||
{
|
||||
for(j = 0; j < o.interactiveObjs.length; j++)
|
||||
{
|
||||
if(checkVolumeUse == null || Boolean(checkVolumeUse != null) && Boolean(checkVolumeUse(o.name)))
|
||||
{
|
||||
ro = o.interactiveObjs[j];
|
||||
ro.setDir(1);
|
||||
ro.mouseDown(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = o;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(i = 0; i < this._volumeActors.length; i++)
|
||||
{
|
||||
o = this._volumeActors[i];
|
||||
if(Boolean(this.isMouseVolume(o.type)) && Boolean(o.interactiveObjs) && this.pointInVolume(p,o.v))
|
||||
{
|
||||
for(j = 0; j < o.interactiveObjs.length; j++)
|
||||
{
|
||||
if(checkVolumeUse == null || Boolean(checkVolumeUse != null) && Boolean(checkVolumeUse(o.name)))
|
||||
{
|
||||
ro = o.interactiveObjs[j];
|
||||
if(!ro.hold)
|
||||
{
|
||||
ro.setDir(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public function testPlantVolumes(p:Point) : Object
|
||||
{
|
||||
var i:int = 0;
|
||||
var o:Object = null;
|
||||
var ret:Object = null;
|
||||
if(Boolean(this._volumeActors))
|
||||
{
|
||||
for(i = 0; i < this._volumeActors.length; i++)
|
||||
{
|
||||
o = this._volumeActors[i];
|
||||
if(this.isPlantVolume(o.type) && this.pointInVolume(p,o.v))
|
||||
{
|
||||
ret = o;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public function setVolumesEnabled(volumeName:String, bEnable:Boolean) : void
|
||||
{
|
||||
var i:int = 0;
|
||||
var o:Object = null;
|
||||
if(Boolean(this._volumeActors))
|
||||
{
|
||||
for(i = 0; i < this._volumeActors.length; i++)
|
||||
{
|
||||
o = this._volumeActors[i];
|
||||
if(o.name == volumeName)
|
||||
{
|
||||
o.enabled = bEnable;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testStealthVolumes(p:Point) : Object
|
||||
{
|
||||
var i:int = 0;
|
||||
var o:Object = null;
|
||||
var ret:Object = null;
|
||||
if(Boolean(this._volumeActors))
|
||||
{
|
||||
for(i = 0; i < this._volumeActors.length; i++)
|
||||
{
|
||||
o = this._volumeActors[i];
|
||||
if(Boolean(o.enabled) && Boolean(this.isStealthVolume(o.type)) && this.pointInVolume(p,o.v))
|
||||
{
|
||||
ret = o;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public function testAvatarVolumes(p:Point) : Object
|
||||
{
|
||||
var i:int = 0;
|
||||
var o:Object = null;
|
||||
var ret:Object = null;
|
||||
if(Boolean(this._volumeActors))
|
||||
{
|
||||
for(i = 0; i < this._volumeActors.length; i++)
|
||||
{
|
||||
o = this._volumeActors[i];
|
||||
if(this.isAvatarVolume(o.type) && this.pointInVolume(p,o.v))
|
||||
{
|
||||
ret = o;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public function testSplashVolumes(p:Point) : Object
|
||||
{
|
||||
var i:int = 0;
|
||||
var o:Object = null;
|
||||
var ret:Object = null;
|
||||
for(i = 0; i < this._splashVolumes.length; i++)
|
||||
{
|
||||
o = this._splashVolumes[i];
|
||||
if(this.pointInVolume(p,o.v))
|
||||
{
|
||||
ret = o;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public function updateSocialTriggers(avList:Object) : void
|
||||
{
|
||||
var key:Object = null;
|
||||
var a:* = undefined;
|
||||
if(Boolean(this._socialTriggersVolumes) && Boolean(this._socialTriggersVolumes.length))
|
||||
{
|
||||
this.clearSocialTriggers();
|
||||
for(key in avList)
|
||||
{
|
||||
a = avList[key];
|
||||
this.testSocialTriggers(new Point(a.x,a.y),a.animId);
|
||||
}
|
||||
this.updateSocialTriggersStage();
|
||||
}
|
||||
}
|
||||
|
||||
private function clearSocialTriggers() : void
|
||||
{
|
||||
var o:Object = null;
|
||||
var o1:Object = null;
|
||||
for each(o in this._socialTriggersVolumes)
|
||||
{
|
||||
for each(o1 in o.interactiveObjs)
|
||||
{
|
||||
if(o1 is RoomObject_SocialTrigger)
|
||||
{
|
||||
o1.clearCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function testSocialTriggers(p:Point, animId:int) : void
|
||||
{
|
||||
var o:Object = null;
|
||||
var o1:Object = null;
|
||||
for each(o in this._socialTriggersVolumes)
|
||||
{
|
||||
if(this.pointInVolume(p,o.v) && (!o.animIds || o.animIds.indexOf(animId) >= 0))
|
||||
{
|
||||
for each(o1 in o.interactiveObjs)
|
||||
{
|
||||
if(o1 is RoomObject_SocialTrigger)
|
||||
{
|
||||
o1.incCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function updateSocialTriggersStage() : void
|
||||
{
|
||||
var o:Object = null;
|
||||
var o1:Object = null;
|
||||
for each(o in this._socialTriggersVolumes)
|
||||
{
|
||||
for each(o1 in o.interactiveObjs)
|
||||
{
|
||||
if(o1 is RoomObject_SocialTrigger)
|
||||
{
|
||||
o1.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function isMouseVolume(type:int) : Boolean
|
||||
{
|
||||
return type == 0 || type == 1 || type == 4 || type == 7 || type == 8 || type == 9 || type == 10 || type == 12 || type == 13;
|
||||
}
|
||||
|
||||
private function isSocialTriggerVolume(type:int) : Boolean
|
||||
{
|
||||
return type == 5;
|
||||
}
|
||||
|
||||
private function isAvatarVolume(type:int) : Boolean
|
||||
{
|
||||
return type == 6 || type == 11;
|
||||
}
|
||||
|
||||
private function isSplashVolume(type:int) : Boolean
|
||||
{
|
||||
return type == 3;
|
||||
}
|
||||
|
||||
private function isPlantVolume(type:int) : Boolean
|
||||
{
|
||||
return type == 18;
|
||||
}
|
||||
|
||||
private function isStealthVolume(type:int) : Boolean
|
||||
{
|
||||
return type == 19;
|
||||
}
|
||||
|
||||
private function newVolume(v:Object) : void
|
||||
{
|
||||
var i:int = 0;
|
||||
var p:Point = null;
|
||||
var layer:Object = null;
|
||||
var o:Object = {
|
||||
"enabled":true,
|
||||
"name":v.name,
|
||||
"v":v.points.slice(),
|
||||
"status":0,
|
||||
"interactiveObjs":null,
|
||||
"message":v.message,
|
||||
"type":v.type,
|
||||
"typeDefId":v.typeDefId,
|
||||
"bWalkTo":v.walkTo
|
||||
};
|
||||
for(i = 0; i < o.v.length; i++)
|
||||
{
|
||||
p = new Point(o.v[i].x,o.v[i].y);
|
||||
this.convertToWorldSpace(p);
|
||||
o.v[i] = p;
|
||||
}
|
||||
for(i = 0; i < this._layers.length; i++)
|
||||
{
|
||||
layer = this._layers[i];
|
||||
if(layer.name == v.name)
|
||||
{
|
||||
if(!o.interactiveObjs)
|
||||
{
|
||||
o.interactiveObjs = [];
|
||||
}
|
||||
o.interactiveObjs.push(this.getRoomObject(layer,v.message));
|
||||
}
|
||||
}
|
||||
this._volumeActors.push(o);
|
||||
if(this.isSplashVolume(o.type))
|
||||
{
|
||||
this._splashVolumes.push(o);
|
||||
}
|
||||
if(this.isSocialTriggerVolume(o.type))
|
||||
{
|
||||
o.animIds = null;
|
||||
if(Boolean(o.message.length))
|
||||
{
|
||||
o.animIds = o.message.split(",");
|
||||
for(i = 0; i < o.animIds.length; i++)
|
||||
{
|
||||
o.animIds[i] = int(o.animIds[i]);
|
||||
}
|
||||
}
|
||||
this._socialTriggersVolumes.push(o);
|
||||
}
|
||||
}
|
||||
|
||||
private function getRoomObject(layer:Object, message:String) : Object
|
||||
{
|
||||
var mc:MovieClip = null;
|
||||
var c:Class = null;
|
||||
var o:RoomObject = this._roomObjs[layer.name];
|
||||
if(!o)
|
||||
{
|
||||
mc = layer.s.content;
|
||||
switch(message)
|
||||
{
|
||||
case "gem":
|
||||
c = RoomObject_GemPickup;
|
||||
break;
|
||||
default:
|
||||
if(mc.stages != null)
|
||||
{
|
||||
c = RoomObject_SocialTrigger;
|
||||
}
|
||||
else if(Boolean(mc.currentLabels.length))
|
||||
{
|
||||
if(mc.currentLabels[0].name == "idle")
|
||||
{
|
||||
c = RoomObject_IdleActive;
|
||||
}
|
||||
else if(mc.currentLabels[0].name == "random")
|
||||
{
|
||||
c = RoomObject_RandomClick;
|
||||
}
|
||||
}
|
||||
if(!c)
|
||||
{
|
||||
c = RoomObject_ForwardReverseHold;
|
||||
}
|
||||
}
|
||||
o = new c(mc);
|
||||
this._roomObjs[layer.name] = o;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
private function pointInVolume(p:Point, v:Array) : Boolean
|
||||
{
|
||||
var vt:Number = NaN;
|
||||
var crossing:Number = 0;
|
||||
var n:Number = v.length - 1;
|
||||
for(var i:int = 0; i < n; i++)
|
||||
{
|
||||
if(v[i].y <= p.y && v[i + 1].y > p.y || v[i].y > p.y && v[i + 1].y <= p.y)
|
||||
{
|
||||
vt = (p.y - v[i].y) / (v[i + 1].y - v[i].y);
|
||||
if(p.x < v[i].x + vt * (v[i + 1].x - v[i].x))
|
||||
{
|
||||
crossing++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Boolean(crossing % 2) ? true : false;
|
||||
}
|
||||
|
||||
private function convertToWorldSpace(pos:Point) : void
|
||||
{
|
||||
pos.x -= this._offset.x;
|
||||
pos.y -= this._offset.y;
|
||||
}
|
||||
|
||||
public function findVolume(name:String) : Array
|
||||
{
|
||||
var i:int = 0;
|
||||
var volumes:Array = null;
|
||||
if(this._volumeActors != null)
|
||||
{
|
||||
while(i < this._volumeActors.length)
|
||||
{
|
||||
if(this._volumeActors[i].name == name)
|
||||
{
|
||||
if(volumes == null)
|
||||
{
|
||||
volumes = new Array();
|
||||
}
|
||||
volumes.push(this._volumeActors[i]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return volumes;
|
||||
}
|
||||
|
||||
public function findVolumesByType(type:int) : Array
|
||||
{
|
||||
var i:int = 0;
|
||||
var volumes:Array = null;
|
||||
if(this._volumeActors != null)
|
||||
{
|
||||
while(i < this._volumeActors.length)
|
||||
{
|
||||
if(this._volumeActors[i].type == type)
|
||||
{
|
||||
if(volumes == null)
|
||||
{
|
||||
volumes = new Array();
|
||||
}
|
||||
volumes.push(this._volumeActors[i]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return volumes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user