示例#1
0
 public void ChangeMapEventRenderPriority(int mapEvent, RenderPriority priority)
 {
     if (mapEvent >= 0 && mapEvent < MapEventEntities.Count)
     {
         _mapInstance.GetMapData().GetMapEvent(mapEvent).Priority = priority;
     }
 }
示例#2
0
        private void Initialize(string name, int dataID, int x, int y)
        {
            Name              = name;
            EventDataID       = dataID;
            MapX              = x;
            MapY              = y;
            RealX             = x * 32;
            RealY             = y * 32;
            EventDirection    = FacingDirection.Down;
            SpriteID          = -1;
            TriggerType       = EventTriggerType.None;
            Passable          = false;
            Priority          = RenderPriority.BelowPlayer;
            Speed             = MovementSpeed.Normal;
            Frequency         = MovementFrequency.Normal;
            ParticleEmitterID = -1;

            RandomMovement = false;
            Enabled        = true;
            Locked         = false;
            OnBridge       = false;

            PositionChanged       = false;
            DirectionChanged      = false;
            SpriteChanged         = false;
            RenderPriorityChanged = false;
            EnabledChanged        = false;
        }
示例#3
0
 private void LoadQualityPreset()
 {
     bloomScattering     = 7f;
     renderPriority      = RenderPriority.Quality;
     quality             = Quality.High;
     allowGlare          = false;
     allowLensFlare      = false;
     lensFlareScattering = 6;
     allowLensSurface    = false;
 }
示例#4
0
 private void LoadMobilePreset()
 {
     bloomScattering     = 5f;
     renderPriority      = RenderPriority.Performance;
     quality             = Quality.Low;
     allowGlare          = false;
     allowLensFlare      = false;
     lensFlareScattering = 5;
     allowLensSurface    = false;
 }
示例#5
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     for (RenderPriority i = RenderPriority.First; i <= RenderPriority.Last; i++)
     {
         comboBox4.Items.Add(i.ToString());
     }
     for (MaterialFlags f = MaterialFlags.None; f <= MaterialFlags.BlendBright_Color; f++)
     {
         comboBox5.Items.Add(f.ToString());
     }
 }
示例#6
0
 public Entity(Position size, Position?renderSize = null, string spriteId = null, string name = null, Position?tileSize = null, RenderPriority renderPriority = RenderPriority.DEFAULT, TagType tag = TagType.TERRAIN, List <TagType> tagsToIgnore = null, bool isTrigger = false)
 {
     Size                  = size;
     SpriteId              = spriteId;
     RenderSize            = renderSize ?? size;
     Name                  = name;
     TileSize              = tileSize ?? Position.zero;
     RenderPrio            = renderPriority;
     Tag                   = tag;
     TagsToIgnoreCollision = tagsToIgnore ?? new List <TagType>();
     IsTrigger             = isTrigger;
 }
示例#7
0
        /// <summary>
        /// This used to be done in the World class but moved here so folks could override a ROL's behavior.
        /// </summary>
        /// <param name="drawArgs"></param>
        /// <param name="priority"></param>
        public virtual void RenderChildren(DrawArgs drawArgs, RenderPriority priority)
        {
            if (!IsOn)
            {
                return;
            }

            m_childrenRWLock.AcquireReaderLock(Timeout.Infinite);
            try
            {
                foreach (RenderableObject ro in this.m_children)
                {
                    if (ro.IsOn)
                    {
                        if ((ro is RenderableObjectList)) //&& !(ro is Icons))
                        {
                            (ro as RenderableObjectList).RenderChildren(drawArgs, priority);
                        }
                        // hack to render both surface images and terrain mapped images.
                        else if (priority == RenderPriority.TerrainMappedImages)
                        {
                            if (ro.RenderPriority == RenderPriority.SurfaceImages || ro.RenderPriority == RenderPriority.TerrainMappedImages)
                            {
                                ro.Render(drawArgs);
                            }
                        }
                        else if (ro.RenderPriority == priority)
                        {
                            ro.Render(drawArgs);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
            }
            finally
            {
                m_childrenRWLock.ReleaseReaderLock();
            }
        }
示例#8
0
        /// <summary>
        /// 绘制地球对象上的图层
        /// </summary>
        /// <param name="renderable"></param>
        /// <param name="priority"></param>
        /// <param name="drawArgs"></param>
        private void Render(RenderableObject renderable, RenderPriority priority, DrawArgs drawArgs)
        {
            //若是绘制星星,则返回,因为星星图层已经绘制过了
            //if (!renderable.IsOn || (renderable.Name != null && renderable.Name.Equals("Starfield")))
            if (!renderable.IsOn || (renderable.Name != null && renderable.Name.Equals("星空")))
            {
                return;
            }

            //绘制Icon图层
            if (priority == RenderPriority.Icons && renderable is Icons)
            {
                renderable.Render(drawArgs);
            }
            else if (priority == RenderPriority.GCPs && renderable is GCPs)
            {
                renderable.Render(drawArgs);
            }
            //绘制RenderableObjectList类型图层下的所有子图层
            else if (renderable is RenderableObjectList)
            {
                RenderableObjectList rol = (RenderableObjectList)renderable;
                for (int i = 0; i < rol.ChildObjects.Count; i++)
                {
                    Render((RenderableObject)rol.ChildObjects[i], priority, drawArgs);
                }
            }
            //绘制RenderPriority.SurfaceImages类型的图层
            else if (priority == RenderPriority.TerrainMappedImages)
            {
                if (renderable.RenderPriority == RenderPriority.SurfaceImages || renderable.RenderPriority == RenderPriority.TerrainMappedImages)
                {
                    renderable.Render(drawArgs);
                }
            }
            //绘制RenderPriority.LinePaths和RenderPriority.AtmosphericImages类型的图层
            else if (renderable.RenderPriority == priority)
            {
                renderable.Render(drawArgs);
            }
        }
示例#9
0
文件: Icons.cs 项目: Fav/testww
        /// <summary>
        /// This used to be done in the World class but moved here so folks could override a ROL's behavior.
        ///
        /// NOTE:  Everything under an Icons is rendered using RenderPriority.Icons.  If you put any other kind of
        /// ROL in here it (and it's children) probably wont render.
        /// </summary>
        /// <param name="drawArgs"></param>
        /// <param name="priority"></param>
        public override void RenderChildren(DrawArgs drawArgs, RenderPriority priority)
        {
            //Respect icon set temporal extents
            if (TimeKeeper.CurrentTimeUtc < EarliestTime || TimeKeeper.CurrentTimeUtc > LatestTime)
            {
                return;
            }

            if (!isOn)
            {
                return;
            }

            if (!isInitialized)
            {
                return;
            }

            if (priority != RenderPriority.Icons)
            {
                return;
            }

            // render ourselves
            this.Render(drawArgs);

            if (m_canUsePointSprites)
            {
                pointSprites.Clear();
            }

            // First render everything except icons - we need to do this twice since the other loop is INSIDE the
            // sprite.begin which can mess up the rendering of other ROs.  This is why prerender is in this loop.
            m_childrenRWLock.AcquireReaderLock(Timeout.Infinite);
            try
            {
                foreach (RenderableObject ro in m_children)
                {
                    if (!ro.IsOn)
                    {
                        continue;
                    }

                    if (ro is Icon) // && (priority == RenderPriority.Icons))
                    {
                        Icon icon = ro as Icon;
                        if (icon == null)
                        {
                            continue;
                        }

                        // do this once for both passes
                        icon.DistanceToIcon = Vector3.Length(icon.Position - drawArgs.WorldCamera.Position);

                        // do PreRender regardless of everything else
                        // note that mouseover actions happen one render cycle after mouse is over icon

                        icon.PreRender(drawArgs, (mouseOverIcon != null) && (icon == mouseOverIcon));
                    }
                    else if (ro is RenderableObjectList)
                    {
                        (ro as RenderableObjectList).RenderChildren(drawArgs, priority);
                    }
                    //// hack to render both surface images and terrain mapped images.
                    //else if (priority == RenderPriority.TerrainMappedImages)
                    //{
                    //    if (ro.RenderPriority == RenderPriority.SurfaceImages || ro.RenderPriority == RenderPriority.TerrainMappedImages)
                    //    {
                    //        ro.Render(drawArgs);
                    //    }
                    //}
                    else  // if (ro.RenderPriority == priority)
                    {
                        ro.Render(drawArgs);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
            }
            finally
            {
                m_childrenRWLock.ReleaseReaderLock();
            }

            m_labelRectangles.Clear();

            int  closestIconDistanceSquared = int.MaxValue;
            Icon closestIcon = null;

            if (priority == RenderPriority.Icons)
            {
                try
                {
                    m_sprite.Begin(SpriteFlags.AlphaBlend);

                    // Now render just the icons
                    m_childrenRWLock.AcquireReaderLock(Timeout.Infinite);
                    try
                    {
                        foreach (RenderableObject ro in m_children)
                        {
                            if (!ro.IsOn)
                            {
                                continue;
                            }

                            Icon icon = ro as Icon;
                            if (icon == null)
                            {
                                continue;
                            }

                            // don't try to render if we aren't in view or too far away
                            if ((drawArgs.WorldCamera.ViewFrustum.ContainsPoint(icon.Position)) &&
                                (icon.DistanceToIcon <= icon.MaximumDisplayDistance) &&
                                (icon.DistanceToIcon >= icon.MinimumDisplayDistance))
                            {
                                Vector3 translationVector = new Vector3(
                                    (float)(icon.PositionD.X - drawArgs.WorldCamera.ReferenceCenter.X),
                                    (float)(icon.PositionD.Y - drawArgs.WorldCamera.ReferenceCenter.Y),
                                    (float)(icon.PositionD.Z - drawArgs.WorldCamera.ReferenceCenter.Z));

                                Vector3 projectedPoint = drawArgs.WorldCamera.Project(translationVector);

                                // check if inside bounding box of icon
                                int dx = DrawArgs.LastMousePosition.X - (int)projectedPoint.X;
                                int dy = DrawArgs.LastMousePosition.Y - (int)projectedPoint.Y;
                                if (icon.SelectionRectangle.Contains(dx, dy))
                                {
                                    // Mouse is over, check whether this icon is closest
                                    int distanceSquared = dx * dx + dy * dy;
                                    if (distanceSquared < closestIconDistanceSquared)
                                    {
                                        closestIconDistanceSquared = distanceSquared;
                                        closestIcon = icon;
                                    }
                                }

                                // mouseover is always one render cycle behind...we mark that an icon is the mouseover
                                // icon and render it normally.  On the NEXT pass it renders as a mouseover icon

                                if (icon != mouseOverIcon)
                                {
                                    // Note: Always render hooked icons as a real icon rather than a sprite.
                                    if (icon.UsePointSprite && (icon.DistanceToIcon > icon.PointSpriteDistance) && m_canUsePointSprites && !icon.IsHooked)
                                    {
                                        PointSpriteVertex pv = new PointSpriteVertex(translationVector.X, translationVector.Y, translationVector.Z, icon.PointSpriteSize, icon.PointSpriteColor.ToArgb());
                                        pointSprites.Add(pv);
                                    }
                                    else
                                    {
                                        // add pointsprite anyway
                                        if (icon.UsePointSprite && icon.AlwaysRenderPointSprite)
                                        {
                                            PointSpriteVertex pv = new PointSpriteVertex(translationVector.X, translationVector.Y, translationVector.Z, icon.PointSpriteSize, icon.PointSpriteColor.ToArgb());
                                            pointSprites.Add(pv);
                                        }

                                        icon.FastRender(drawArgs, m_sprite, projectedPoint, false, m_labelRectangles);
                                    }
                                }
                            }
                            else
                            {
                                // do whatever we're supposed to do if we're not in view or too far away
                                icon.NoRender(drawArgs);
                            }

                            // do post rendering even if we don't render
                            // note that mouseover actions happen one render cycle after mouse is over icon
                            icon.PostRender(drawArgs, icon == mouseOverIcon);
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine(ex.Message.ToString());
                    }
                    finally
                    {
                        m_childrenRWLock.ReleaseReaderLock();
                    }

                    // Clear the rectangles so that mouseover label always appears
                    m_labelRectangles.Clear();

                    // Render the mouse over icon last (on top)
                    if (mouseOverIcon != null)
                    {
                        Vector3 translationVector = new Vector3(
                            (float)(mouseOverIcon.PositionD.X - drawArgs.WorldCamera.ReferenceCenter.X),
                            (float)(mouseOverIcon.PositionD.Y - drawArgs.WorldCamera.ReferenceCenter.Y),
                            (float)(mouseOverIcon.PositionD.Z - drawArgs.WorldCamera.ReferenceCenter.Z));

                        Vector3 projectedPoint = drawArgs.WorldCamera.Project(translationVector);

                        if (mouseOverIcon.UsePointSprite && mouseOverIcon.AlwaysRenderPointSprite && m_canUsePointSprites)
                        {
                            // add pointsprite anyway
                            PointSpriteVertex pv = new PointSpriteVertex(translationVector.X, translationVector.Y, translationVector.Z, mouseOverIcon.PointSpriteSize, mouseOverIcon.PointSpriteColor.ToArgb());
                            pointSprites.Add(pv);
                        }

                        mouseOverIcon.FastRender(drawArgs, m_sprite, projectedPoint, true, m_labelRectangles);
                    }

                    // set new mouseover icon
                    mouseOverIcon = closestIcon;
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine(ex.Message.ToString());
                }
                finally
                {
                    m_sprite.End();
                }

                // render point sprites if any in the list
                try
                {
                    if (pointSprites.Count > 0)
                    {
                        // save device state
                        Texture       origTexture           = drawArgs.device.GetTexture(0);
                        VertexFormats origVertexFormat      = drawArgs.device.VertexFormat;
                        float         origPointScaleA       = drawArgs.device.RenderState.PointScaleA;
                        float         origPointScaleB       = drawArgs.device.RenderState.PointScaleB;
                        float         origPointScaleC       = drawArgs.device.RenderState.PointScaleC;
                        bool          origPointSpriteEnable = drawArgs.device.RenderState.PointSpriteEnable;
                        bool          origPointScaleEnable  = drawArgs.device.RenderState.PointScaleEnable;
                        Blend         origSourceBlend       = drawArgs.device.RenderState.SourceBlend;
                        Blend         origDestBlend         = drawArgs.device.RenderState.DestinationBlend;

                        // set device to do point sprites
                        drawArgs.device.SetTexture(0, m_pointTexture.Texture);
                        drawArgs.device.VertexFormat            = VertexFormats.Position | VertexFormats.PointSize | VertexFormats.Diffuse;
                        drawArgs.device.RenderState.PointScaleA = 1f;
                        drawArgs.device.RenderState.PointScaleB = 0f;
                        drawArgs.device.RenderState.PointScaleC = 0f;
                        //drawArgs.device.RenderState.PointScaleA = 0f;
                        //drawArgs.device.RenderState.PointScaleB = 0f;
                        //drawArgs.device.RenderState.PointScaleC = .0000000000001f;
                        drawArgs.device.RenderState.PointSpriteEnable = true;
                        drawArgs.device.RenderState.PointScaleEnable  = true;
                        drawArgs.device.RenderState.SourceBlend       = Blend.One;
                        drawArgs.device.RenderState.DestinationBlend  = Blend.InvSourceAlpha;

                        drawArgs.device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.Modulate);
                        drawArgs.device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor);
                        drawArgs.device.SetTextureStageState(0, TextureStageStates.ColorArgument2, (int)TextureArgument.Diffuse);

                        drawArgs.device.DrawUserPrimitives(PrimitiveType.PointList, pointSprites.Count, pointSprites.ToArray());

                        // restore device state
                        drawArgs.device.SetTexture(0, origTexture);
                        drawArgs.device.VertexFormat                  = origVertexFormat;
                        drawArgs.device.RenderState.PointScaleA       = origPointScaleA;
                        drawArgs.device.RenderState.PointScaleB       = origPointScaleB;
                        drawArgs.device.RenderState.PointScaleC       = origPointScaleC;
                        drawArgs.device.RenderState.PointSpriteEnable = origPointSpriteEnable;
                        drawArgs.device.RenderState.PointScaleEnable  = origPointScaleEnable;
                        drawArgs.device.RenderState.SourceBlend       = origSourceBlend;
                        drawArgs.device.RenderState.DestinationBlend  = origDestBlend;
                    }
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine(ex.Message.ToString());
                }
            }
        }
示例#10
0
        public static MapEvent FromBytes(byte[] bytes)
        {
            using (MemoryStream stream = new MemoryStream(bytes))
            {
                byte[] tempBytes = new byte[sizeof(int)];
                stream.Read(tempBytes, 0, sizeof(int));
                int nameLength = BitConverter.ToInt32(tempBytes, 0);

                tempBytes = new byte[nameLength];
                stream.Read(tempBytes, 0, nameLength);
                string name = new string(Encoding.UTF8.GetChars(tempBytes, 0, nameLength));

                tempBytes = new byte[sizeof(int)];
                stream.Read(tempBytes, 0, sizeof(int));
                int eventDataID = BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                int mapX = BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                int mapY = BitConverter.ToInt32(tempBytes, 0);

                tempBytes = new byte[sizeof(float)];
                stream.Read(tempBytes, 0, sizeof(float));
                float realX = BitConverter.ToSingle(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(float));
                float realY = BitConverter.ToSingle(tempBytes, 0);

                tempBytes = new byte[sizeof(int)];
                stream.Read(tempBytes, 0, sizeof(int));
                FacingDirection direction = (FacingDirection)BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                int spriteID = BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                EventTriggerType triggerType = (EventTriggerType)BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                RenderPriority priority = (RenderPriority)BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                MovementSpeed speed = (MovementSpeed)BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                int particleEmitterID = BitConverter.ToInt32(tempBytes, 0);

                tempBytes = new byte[sizeof(bool)];
                stream.Read(tempBytes, 0, sizeof(bool));
                bool enabled = BitConverter.ToBoolean(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(bool));
                bool onBridge = BitConverter.ToBoolean(tempBytes, 0);

                MapEvent mapEvent = new MapEvent(name, eventDataID, mapX, mapY);
                mapEvent.RealX             = realX;
                mapEvent.RealY             = realY;
                mapEvent.EventDirection    = direction;
                mapEvent.SpriteID          = spriteID;
                mapEvent.TriggerType       = triggerType;
                mapEvent.Enabled           = enabled;
                mapEvent.Priority          = priority;
                mapEvent.Speed             = speed;
                mapEvent.OnBridge          = onBridge;
                mapEvent.ParticleEmitterID = particleEmitterID;
                return(mapEvent);
            }
        }
示例#11
0
        private void RecieveServerCommand()
        {
            byte[] bytes      = ReadData(sizeof(int), _networkStream);
            int    packetSize = BitConverter.ToInt32(bytes, 0);

            bytes = ReadData(packetSize, _networkStream);
            ServerCommand command = ServerCommand.FromBytes(bytes);

            int             eventID;
            int             enemyID;
            int             enemyIndex;
            int             mapID;
            int             mapX;
            int             mapY;
            float           realX;
            float           realY;
            FacingDirection direction;
            MapData         map;
            int             projectileID;
            int             playerID;
            string          playerName;
            int             itemIndex;
            int             itemID;
            int             count;

            switch (command.GetCommandType())
            {
            case ServerCommand.CommandType.Disconnect:
                this.Disconnect();
                Console.WriteLine("Server Disconnected");
                break;

            case ServerCommand.CommandType.ShowMessage:

                if (_messageBox == null)
                {
                    _messageBox = new MessageBox((string)command.GetParameter("Message"), _gameState, false);
                    _gameState.AddControl(_messageBox);
                }

                break;

            case ServerCommand.CommandType.ShowOptions:

                if (_messageBox == null)
                {
                    string message = (string)command.GetParameter("Message");
                    _messageBox = new MessageBox(message, _gameState, false);
                    string[] options = ((string)command.GetParameter("Options")).Split(',');
                    for (int i = 0; i < options.Length; i++)
                    {
                        _messageBox.AddOption(options[i]);
                    }
                    _messageBox.SetSelectedOption(0);
                    _gameState.AddControl(_messageBox);
                }

                break;

            case ServerCommand.CommandType.AddMapEnemy:

                enemyID = (int)command.GetParameter("EnemyID");
                mapID   = (int)command.GetParameter("MapID");
                if (_gameState.MapEntity.FindComponent <MapComponent>().GetMapInstance().GetMapPacket().MapID == mapID)
                {
                    mapX = (int)command.GetParameter("MapX");
                    mapY = (int)command.GetParameter("MapY");
                    bool     onBridge = (bool)command.GetParameter("OnBridge");
                    MapEnemy mapEnemy = new MapEnemy(enemyID, mapX, mapY, onBridge);
                    MapComponent.Instance.AddMapEnemy(mapEnemy);
                }

                break;

            case ServerCommand.CommandType.UpdateMapEnemy:

                enemyIndex = (int)command.GetParameter("EnemyIndex");
                mapID      = (int)command.GetParameter("MapID");
                if ((_gameState.MapEntity.FindComponent <MapComponent>()).GetMapInstance().GetMapPacket().MapID == mapID)
                {
                    int HP = (int)command.GetParameter("HP");
                    mapX      = (int)command.GetParameter("MapX");
                    mapY      = (int)command.GetParameter("MapY");
                    realX     = (float)command.GetParameter("RealX");
                    realY     = (float)command.GetParameter("RealY");
                    direction = (FacingDirection)command.GetParameter("Direction");
                    bool onBridge = (bool)command.GetParameter("OnBridge");
                    bool dead     = (bool)command.GetParameter("Dead");
                    MapEnemyComponent enemyComponent = MapComponent.Instance.EnemyEntites[enemyIndex].FindComponent <MapEnemyComponent>();
                    enemyComponent.UpdateMapEnemy(HP, mapX, mapY, realX, realY, direction, onBridge, dead);

                    if (dead)
                    {
                        MapComponent.Instance.EnemyEntites[enemyIndex].Destroy();
                        MapComponent.Instance.EnemyEntites.RemoveAt(enemyIndex);
                        MapComponent.Instance.GetMapInstance().RemoveMapEnemy(enemyIndex);
                    }
                }

                break;

            case ServerCommand.CommandType.UpdateMapEvent:

                eventID = (int)command.GetParameter("EventID");
                mapID   = (int)command.GetParameter("MapID");
                if (_gameState.MapEntity.FindComponent <MapComponent>().GetMapInstance().GetMapPacket().MapID == mapID)
                {
                    mapX      = (int)command.GetParameter("MapX");
                    mapY      = (int)command.GetParameter("MapY");
                    realX     = (float)command.GetParameter("RealX");
                    realY     = (float)command.GetParameter("RealY");
                    direction = (FacingDirection)command.GetParameter("Direction");
                    bool onBridge = (bool)command.GetParameter("OnBridge");

                    map = _gameState.MapEntity.FindComponent <MapComponent>().GetMapInstance().GetMapData();
                    if (map != null)
                    {
                        map.GetMapEvent(eventID).MapX           = mapX;
                        map.GetMapEvent(eventID).MapY           = mapY;
                        map.GetMapEvent(eventID).RealX          = realX;
                        map.GetMapEvent(eventID).RealY          = realY;
                        map.GetMapEvent(eventID).EventDirection = direction;
                        map.GetMapEvent(eventID).OnBridge       = onBridge;
                    }
                }

                break;

            case ServerCommand.CommandType.ChangeMapEventDirection:

                eventID = (int)command.GetParameter("EventID");
                mapID   = (int)command.GetParameter("MapID");
                if (_gameState.MapEntity.FindComponent <MapComponent>().GetMapInstance().GetMapPacket().MapID == mapID)
                {
                    direction = (FacingDirection)command.GetParameter("Direction");

                    map = _gameState.MapEntity.FindComponent <MapComponent>().GetMapInstance().GetMapData();
                    if (map != null)
                    {
                        map.GetMapEvent(eventID).EventDirection = direction;
                    }
                }

                break;

            case ServerCommand.CommandType.ChangeMapEventSprite:

                mapID = (int)command.GetParameter("MapID");
                if (_gameState.MapEntity.FindComponent <MapComponent>().GetMapInstance().GetMapPacket().MapID == mapID)
                {
                    eventID = (int)command.GetParameter("EventID");
                    int spriteID = (int)command.GetParameter("SpriteID");
                    _gameState.MapEntity.FindComponent <MapComponent>().ChangeMapEventSprite(eventID, spriteID);
                }

                break;

            case ServerCommand.CommandType.ChangeMapEventRenderPriority:

                mapID = (int)command.GetParameter("MapID");
                if (_gameState.MapEntity.FindComponent <MapComponent>().GetMapInstance().GetMapPacket().MapID == mapID)
                {
                    eventID = (int)command.GetParameter("EventID");
                    RenderPriority priority = (RenderPriority)command.GetParameter("RenderPriority");
                    _gameState.MapEntity.FindComponent <MapComponent>().ChangeMapEventRenderPriority(eventID, priority);
                }

                break;

            case ServerCommand.CommandType.ChangeMapEventEnabled:

                mapID = (int)command.GetParameter("MapID");
                if (_gameState.MapEntity.FindComponent <MapComponent>().GetMapInstance().GetMapPacket().MapID == mapID)
                {
                    eventID = (int)command.GetParameter("EventID");
                    bool enabled = (bool)command.GetParameter("Enabled");
                    _gameState.MapEntity.FindComponent <MapComponent>().ChangeMapEventEnabled(eventID, enabled);
                }

                break;

            case ServerCommand.CommandType.AddProjectile:

                mapID = (int)command.GetParameter("MapID");
                if (_gameState.MapEntity.FindComponent <MapComponent>().GetMapInstance().GetMapPacket().MapID == mapID)
                {
                    {
                        int dataID = (int)command.GetParameter("DataID");
                        realX     = (float)command.GetParameter("RealX");
                        realY     = (float)command.GetParameter("RealY");
                        direction = (FacingDirection)command.GetParameter("Direction");
                        bool onBridge = (bool)command.GetParameter("OnBridge");

                        MapProjectile projectile = new MapProjectile(dataID, CharacterType.Player, -1, new Vector2(realX, realY), direction);
                        projectile.OnBridge = onBridge;
                        MapComponent.Instance.AddMapProjectile(projectile);
                    }
                }

                break;

            case ServerCommand.CommandType.UpdateProjectile:

                mapID = (int)command.GetParameter("MapID");
                if (_gameState.MapEntity.FindComponent <MapComponent>().GetMapInstance().GetMapPacket().MapID == mapID)
                {
                    projectileID = (int)command.GetParameter("ProjectileID");
                    if (projectileID < MapComponent.Instance.ProjectileEntites.Count)
                    {
                        realX = (float)command.GetParameter("RealX");
                        realY = (float)command.GetParameter("RealY");
                        bool onBridge  = (bool)command.GetParameter("OnBridge");
                        bool destroyed = (bool)command.GetParameter("Destroyed");
                        ProjectileComponent component = MapComponent.Instance.ProjectileEntites[projectileID].FindComponent <ProjectileComponent>();
                        component.SetRealPosition(realX, realY);
                        component.SetOnBridge(onBridge);
                        if (destroyed)
                        {
                            MapComponent.Instance.ProjectileEntites[projectileID].Destroy();
                            MapComponent.Instance.ProjectileEntites.RemoveAt(projectileID);
                            MapComponent.Instance.GetMapInstance().RemoveMapProjectile(projectileID);
                        }
                    }
                }

                break;

            case ServerCommand.CommandType.AddMapItem:

                mapID = (int)command.GetParameter("MapID");
                MapComponent mapComponent = _gameState.MapEntity.FindComponent <MapComponent>();
                if (mapComponent.GetMapInstance().GetMapPacket().MapID == mapID)
                {
                    itemID   = (int)command.GetParameter("ItemID");
                    count    = (int)command.GetParameter("Count");
                    mapX     = (int)command.GetParameter("MapX");
                    mapY     = (int)command.GetParameter("MapY");
                    playerID = (int)command.GetParameter("PlayerID");
                    bool    onBridge = (bool)command.GetParameter("OnBridge");
                    MapItem mapItem  = new MapItem(itemID, count, mapX, mapY, playerID, onBridge);
                    MapComponent.Instance.AddMapItem(mapItem);
                }

                break;

            case ServerCommand.CommandType.RemoveMapItem:

                mapID = (int)command.GetParameter("MapID");
                if (_gameState.MapEntity.FindComponent <MapComponent>().GetMapInstance().GetMapPacket().MapID == mapID)
                {
                    itemIndex = (int)command.GetParameter("ItemIndex");
                    if (itemIndex < MapComponent.Instance.MapItemEntities.Count)
                    {
                        MapComponent.Instance.MapItemEntities[itemIndex].Destroy();
                        MapComponent.Instance.MapItemEntities.RemoveAt(itemIndex);
                        MapComponent.Instance.GetMapInstance().RemoveMapItem(itemIndex);
                    }
                }

                break;

            case ServerCommand.CommandType.UpdateMapItem:

                mapID = (int)command.GetParameter("MapID");
                if (_gameState.MapEntity.FindComponent <MapComponent>().GetMapInstance().GetMapPacket().MapID == mapID)
                {
                    itemIndex = (int)command.GetParameter("ItemIndex");
                    if (itemIndex < MapComponent.Instance.MapItemEntities.Count)
                    {
                        playerID = (int)command.GetParameter("PlayerID");
                        count    = (int)command.GetParameter("Count");
                        MapComponent.Instance.MapItemEntities[itemIndex].FindComponent <MapItemComponent>().GetMapItem().PlayerID = playerID;
                        MapComponent.Instance.MapItemEntities[itemIndex].FindComponent <MapItemComponent>().GetMapItem().Count    = count;
                    }
                }

                break;

            case ServerCommand.CommandType.ShowShop:

                int      shopID = (int)command.GetParameter("ShopID");
                ShopData data   = ShopData.GetData(shopID);
                if (data != null)
                {
                    if (InventoryPanel.Instance == null)
                    {
                        GameState.Instance.ToggleInventory();
                    }
                    _gameState.AddControl(new GUI.ShopPanel(_gameState, data));
                }
                else
                {
                    AddClientCommand(new ClientCommand(ClientCommand.CommandType.CloseShop));
                }

                break;

            case ServerCommand.CommandType.TradeRequest:
                playerID   = (int)command.GetParameter("PlayerID");
                playerName = (string)command.GetParameter("PlayerName");
                MessagePanel.Instance.AddMessage(playerName + " would like to trade.");

                break;

            case ServerCommand.CommandType.StartTrade:
                playerID   = (int)command.GetParameter("PlayerID");
                playerName = (string)command.GetParameter("PlayerName");

                if (InventoryPanel.Instance == null)
                {
                    GameState.Instance.ToggleInventory();
                }

                _gameState.AddControl(new GUI.TradePanel(_gameState, playerID, playerName));
                break;

            case ServerCommand.CommandType.AcceptTrade:
                if (TradePanel.Instance != null)
                {
                    TradePanel.Instance.TradeRequest.TradeOffer2.Accepted = true;
                }
                break;

            case ServerCommand.CommandType.EndTrade:
                if (TradePanel.Instance != null)
                {
                    TradePanel.Instance.Close();
                }
                break;

            case ServerCommand.CommandType.AddTradeItem:
                itemID = (int)command.GetParameter("ItemID");
                count  = (int)command.GetParameter("Count");

                if (TradePanel.Instance != null)
                {
                    TradePanel.Instance.TradeRequest.TradeOffer2.AddItem(itemID, count);
                    TradePanel.Instance.TradeRequest.TradeOffer1.Accepted = false;
                    TradePanel.Instance.TradeRequest.TradeOffer2.Accepted = false;
                }

                break;

            case ServerCommand.CommandType.RemoveTradeItem:
                itemIndex = (int)command.GetParameter("ItemIndex");
                count     = (int)command.GetParameter("Count");

                if (TradePanel.Instance != null)
                {
                    TradePanel.Instance.TradeRequest.TradeOffer2.RemoveItem(itemIndex, count);
                    TradePanel.Instance.TradeRequest.TradeOffer1.Accepted = false;
                    TradePanel.Instance.TradeRequest.TradeOffer2.Accepted = false;
                }

                break;

            case ServerCommand.CommandType.CantTrade:
                if (TradePanel.Instance != null)
                {
                    TradePanel.Instance.TradeRequest.TradeOffer1.Accepted = false;
                    TradePanel.Instance.TradeRequest.TradeOffer2.Accepted = false;
                }
                break;

            case ServerCommand.CommandType.OpenBank:
                if (InventoryPanel.Instance == null)
                {
                    GameState.Instance.ToggleInventory();
                }

                _gameState.AddControl(new BankPanel(_gameState));

                break;

            case ServerCommand.CommandType.ShowWorkbench:
                int workbenchID = (int)command.GetParameter("WorkbenchID");

                if (InventoryPanel.Instance == null)
                {
                    GameState.Instance.ToggleInventory();
                }

                _gameState.AddControl(new GUI.WorkbenchPanel(_gameState, workbenchID));

                break;
            }
        }