// Public Methods (1) public void Load(string XMLFile) { XPathDocument _doc = new XPathDocument(XMLFile); XPathNavigator _nav = _doc.CreateNavigator(); XPathExpression _expr; _expr = _nav.Compile("/edgefile"); XPathNodeIterator _Iter = _nav.Select(_expr); _Iter.MoveNext(); var _Nav2 = _Iter.Current.Clone(); Name = _Nav2.GetAttribute("name", ""); ID = _Nav2.GetAttribute("id", "").ParseXMLFunction(); ImageFile = _Nav2.GetAttribute("imagefile", ""); _expr = _nav.Compile("/edgefile/edge"); XPathNodeIterator _ScreenIterator = null; _Nav2 = null; _ScreenIterator = _nav.Select(_expr); while (_ScreenIterator.MoveNext()) { var _EdgeNav = _ScreenIterator.Current.Clone(); Rectangle _R = new Rectangle(); _R = _R.FromString(_EdgeNav.GetAttribute("imagerec", "")); Enumerations.RelativePosition _P = (Enumerations.RelativePosition)Enum.Parse(typeof(Enumerations.RelativePosition), _EdgeNav.GetAttribute("direction", "")); _ImageLocation.Add(_P, _R); } }
/// <summary> /// Draw A Single Screen That Which Is 800,600 /// </summary> /// <param name="X">Position X In The World</param> /// <param name="Y">Position Y In The World</param> /// <returns></returns> public Image DrawLocation_SingleScreen(int X, int Y, bool DrawObjects) { _SingleScreenGraphicsObject.Clear(Color.FromArgb(0, 255, 0)); #region Draw Each Of The Layers foreach (var Layer in _Layers) { if (Layer.Value.Visible) { if (Screens.ContainsKey(GetKey(X, Y, Enumerations.RelativePosition.Main))) { _SingleScreenGraphicsObject.DrawImage(Screens[GetKey(X, Y, Enumerations.RelativePosition.Main)].GetLayerImage(Layer.Key.ToLower()), new Point(0, 0)); } } } #endregion if (DrawObjects) { #region Draw Objects On Screen var AllObjs = from QMapObject in Screens.Values.SelectMany(x => x.MapObjects) where QMapObject.Screen.InRange(X, Y, OffsetX, OffsetY) orderby QMapObject.DrawLocation.Y select new { QMapObject, QMapObject.Screen.X, QMapObject.Screen.Y }; foreach (var MapO in AllObjs) { Enumerations.RelativePosition _RPos = EditorScreen.GetRelativePos(X, Y, MapO.X, MapO.Y); if (_RPos == Enumerations.RelativePosition.Main) { Point _DrawPoint = new Point(MapO.QMapObject.DrawLocation.X, MapO.QMapObject.DrawLocation.Y); _SingleScreenGraphicsObject.DrawImage(ResourceManager.GetMapObjectImageStart(MapO.QMapObject.ID.ToString()), _DrawPoint); } } #endregion #region Draw The Selected Object if (SelectedMapObject != Guid.Empty) { var SelectedObjs = from QMapObject in Screens.Values.SelectMany(x => x.MapObjects) where QMapObject.ID == SelectedMapObject select QMapObject; var FirstObject = SelectedObjs.ToList()[0]; _SingleScreenGraphicsObject.DrawRectangle(Pens.White, new Rectangle(new Point(FirstObject.DrawLocation.X + OffsetX, FirstObject.DrawLocation.Y + OffsetY), FirstObject.ImageSize)); } #endregion } // Draw The Bounding Box for Refrence _SingleScreenGraphicsObject.DrawRectangle(Pens.Black, new Rectangle(-1, -1, 800, 600)); return(_SingleScreenImage); }
public void SetAnimation(string Name, Enumerations.RelativePosition Position) { if (_CurrentFacePos == Position && Name == _CurrentAnimation) { return; } _CurrentFacePos = Position; _CurrentAnimation = Name; _CurrentFrame = 0; return; }
/// <summary> /// Gets the String Representation Of The X,Y Coordinates and the Relative Position /// </summary> /// <param name="X">World X</param> /// <param name="Y">World Y</param> /// <param name="P">Visible X,Y Relative Position To X,Y</param> /// <returns></returns> public static string GetKey(int X, int Y, Enumerations.RelativePosition P) { int _tx, _ty; _tx = X; _ty = Y; StringBuilder _SB = new StringBuilder(); if (P == Enumerations.RelativePosition.Left) { _tx--; } else if (P == Enumerations.RelativePosition.Bottom) { _ty++; } else if (P == Enumerations.RelativePosition.Right) { _tx++; } else if (P == Enumerations.RelativePosition.Top) { _ty--; } else if (P == Enumerations.RelativePosition.TopLeft) { _tx--; _ty--; } else if (P == Enumerations.RelativePosition.TopRight) { _tx++; _ty--; } else if (P == Enumerations.RelativePosition.BottomRight) { _tx++; _ty++; } else if (P == Enumerations.RelativePosition.BottomLeft) { _tx--; _ty++; } _SB.Append(_tx); _SB.Append("-"); _SB.Append(_ty); return(_SB.ToString()); }
public static string ToScreenKey(this Microsoft.Xna.Framework.Point Pn, Enumerations.RelativePosition P) { int _tx, _ty; _tx = Pn.X; _ty = Pn.Y; StringBuilder _SB = new StringBuilder(); if (P == Enumerations.RelativePosition.Left) { _tx--; } else if (P == Enumerations.RelativePosition.Bottom) { _ty++; } else if (P == Enumerations.RelativePosition.Right) { _tx++; } else if (P == Enumerations.RelativePosition.Top) { _ty--; } else if (P == Enumerations.RelativePosition.TopLeft) { _tx--; _ty--; } else if (P == Enumerations.RelativePosition.TopRight) { _tx++; _ty--; } else if (P == Enumerations.RelativePosition.BottomRight) { _tx++; _ty++; } else if (P == Enumerations.RelativePosition.BottomLeft) { _tx--; _ty++; } _SB.Append(_tx); _SB.Append("-"); _SB.Append(_ty); return(_SB.ToString()); }
/// <summary> /// Draws the specified Location. This Should Never Be Called Consecutavly. The Editor Only calls It /// One Time The After It Updates The Editor Screens With Any changes. Also On A resize or A Paint /// </summary> /// <param name="X"></param> /// <param name="Y"></param> /// <returns></returns> public Image DrawLocation(int X, int Y) { _G.Clear(Color.FromArgb(255, 255, 255)); #region Draw Each Of The Layers foreach (var Layer in _Layers) { if (Layer.Value.Visible) { if (Screens.ContainsKey(GetKey(X, Y, Enumerations.RelativePosition.Main))) { _G.DrawImage(Screens[GetKey(X, Y, Enumerations.RelativePosition.Main)].GetLayerImage(Layer.Key.ToLower()), new Point(OffsetX, OffsetY)); } if (Screens.ContainsKey(GetKey(X, Y, Enumerations.RelativePosition.Left))) { _G.DrawImage(Screens[GetKey(X, Y, Enumerations.RelativePosition.Left)].GetLayerImage(Layer.Key.ToLower()), new Rectangle(0, OffsetY, OffsetX, 600), new Rectangle(800 - OffsetX, 0, OffsetX, 600), GraphicsUnit.Pixel); } if (Screens.ContainsKey(GetKey(X, Y, Enumerations.RelativePosition.Right))) { _G.DrawImage(Screens[GetKey(X, Y, Enumerations.RelativePosition.Right)].GetLayerImage(Layer.Key.ToLower()), new Rectangle(800 + OffsetX, OffsetY, OffsetX, 600), new Rectangle(0, 0, OffsetX, 600), GraphicsUnit.Pixel); } if (Screens.ContainsKey(GetKey(X, Y, Enumerations.RelativePosition.Bottom))) { _G.DrawImage(Screens[GetKey(X, Y, Enumerations.RelativePosition.Bottom)].GetLayerImage(Layer.Key.ToLower()), new Rectangle(OffsetX, 600 + OffsetY, 800, OffsetY), new Rectangle(0, 0, 800, OffsetY), GraphicsUnit.Pixel); } if (Screens.ContainsKey(GetKey(X, Y, Enumerations.RelativePosition.Top))) { _G.DrawImage(Screens[GetKey(X, Y, Enumerations.RelativePosition.Top)].GetLayerImage(Layer.Key.ToLower()), new Rectangle(OffsetX, 0, 800, OffsetY), new Rectangle(0, 600 - OffsetY, 800, OffsetY), GraphicsUnit.Pixel); } if (Screens.ContainsKey(GetKey(X, Y, Enumerations.RelativePosition.TopLeft))) { _G.DrawImage(Screens[GetKey(X, Y, Enumerations.RelativePosition.TopLeft)].GetLayerImage(Layer.Key.ToLower()), new Rectangle(0, 0, OffsetX, OffsetY), new Rectangle(800 - OffsetX, 600 - OffsetY, OffsetX, OffsetY), GraphicsUnit.Pixel); } if (Screens.ContainsKey(GetKey(X, Y, Enumerations.RelativePosition.TopRight))) { _G.DrawImage(Screens[GetKey(X, Y, Enumerations.RelativePosition.TopRight)].GetLayerImage(Layer.Key.ToLower()), new Rectangle(800 + OffsetX, 0, OffsetX, OffsetY), new Rectangle(0, 600 - OffsetY, OffsetX, OffsetY), GraphicsUnit.Pixel); } if (Screens.ContainsKey(GetKey(X, Y, Enumerations.RelativePosition.BottomRight))) { _G.DrawImage(Screens[GetKey(X, Y, Enumerations.RelativePosition.BottomRight)].GetLayerImage(Layer.Key.ToLower()), new Rectangle(800 + OffsetX, 600 + OffsetY, OffsetX, OffsetY), new Rectangle(0, 0, OffsetX, OffsetY), GraphicsUnit.Pixel); } if (Screens.ContainsKey(GetKey(X, Y, Enumerations.RelativePosition.BottomLeft))) { _G.DrawImage(Screens[GetKey(X, Y, Enumerations.RelativePosition.BottomLeft)].GetLayerImage(Layer.Key.ToLower()), new Rectangle(0, 600 + OffsetY, OffsetX, OffsetY), new Rectangle(800 - OffsetX, 0, OffsetX, OffsetY), GraphicsUnit.Pixel); } } } #endregion #region Draw The Objects var AllObjs = from QMapObject in Screens.Values.SelectMany(x => x.MapObjects) where QMapObject.Screen.InRange(X, Y, OffsetX, OffsetY) orderby QMapObject.DrawLocation.Y select new { QMapObject, QMapObject.Screen.X, QMapObject.Screen.Y }; foreach (var MapO in AllObjs) { Enumerations.RelativePosition _RPos = EditorScreen.GetRelativePos(X, Y, MapO.X, MapO.Y); if (_RPos == Enumerations.RelativePosition.Main) { Point _DrawPoint = new Point(MapO.QMapObject.DrawLocation.X + OffsetX, MapO.QMapObject.DrawLocation.Y + OffsetY); _G.DrawImage(ResourceManager.GetMapObjectImageStart(MapO.QMapObject.ID.ToString()), _DrawPoint); } else if (_RPos == Enumerations.RelativePosition.Right) { Point _DrawPoint = new Point(MapO.QMapObject.DrawLocation.X + 800 + OffsetX, MapO.QMapObject.DrawLocation.Y + OffsetY); _G.DrawImage(ResourceManager.GetMapObjectImageStart(MapO.QMapObject.ID.ToString()), _DrawPoint); } else if (_RPos == Enumerations.RelativePosition.Left) { Point _DrawPoint = new Point(MapO.QMapObject.DrawLocation.X - 800, MapO.QMapObject.DrawLocation.Y + OffsetY); _G.DrawImage(ResourceManager.GetMapObjectImageStart(MapO.QMapObject.ID.ToString()), _DrawPoint); } else if (_RPos == Enumerations.RelativePosition.Top) { Point _DrawPoint = new Point(MapO.QMapObject.DrawLocation.X + OffsetX, MapO.QMapObject.DrawLocation.Y - 600); _G.DrawImage(ResourceManager.GetMapObjectImageStart(MapO.QMapObject.ID.ToString()), _DrawPoint); } else if (_RPos == Enumerations.RelativePosition.Bottom) { Point _DrawPoint = new Point(MapO.QMapObject.DrawLocation.X + OffsetX, MapO.QMapObject.DrawLocation.Y + 600); _G.DrawImage(ResourceManager.GetMapObjectImageStart(MapO.QMapObject.ID.ToString()), _DrawPoint); } } #endregion #region Draw The Selected Object if (SelectedMapObject != Guid.Empty) { var SelectedObjs = from QMapObject in Screens.Values.SelectMany(x => x.MapObjects) where QMapObject.ID == SelectedMapObject select QMapObject; var FirstObject = SelectedObjs.ToList()[0]; _G.DrawRectangle(Pens.White, new Rectangle(new Point(FirstObject.DrawLocation.X + OffsetX, FirstObject.DrawLocation.Y + OffsetY), FirstObject.ImageSize)); } #endregion // Draw The Bounding Box for Refrence _G.DrawRectangle(Pens.Black, new Rectangle(OffsetX - 1, OffsetY - 1, 800, 600)); return(_BackBufferImage); }