Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.DirectX.Direct3D;
  6. using System.Drawing;
  7. using MapleLib.WzLib.WzProperties;
  8.  
  9. namespace WzExplorer.Mapping
  10. {
  11.     class MapList
  12.     {
  13.         private string desc, Name;
  14.         private WzCanvasProperty Dot;
  15.         private WzVectorProperty DotOrigin;
  16.         private Texture texture;
  17.         private Point Spot;
  18.         private Point _position = Point.Empty;
  19.         private bool canDraw;
  20.         private int type;
  21.         public Microsoft.DirectX.DirectInput.Device Mouse;
  22.  
  23.         public MapList(Microsoft.DirectX.Direct3D.Device DxDevice, Microsoft.DirectX.DirectInput.Device mouse, int type, WzVectorProperty Spot, WzVectorProperty baseOrigin)
  24.         {
  25.             this.Mouse = mouse;
  26.             switch (type)
  27.             {
  28.                 case 0:
  29.                     Dot = ((WzCanvasProperty)Mapper.obj.wz.GetObjectFromPath("Map.wz/MapHelper.img/worldMap/mapImage/0"));
  30.                     DotOrigin = ((WzVectorProperty)Dot["origin"]);
  31.                     break;
  32.                 case 1:
  33.                     Dot = ((WzCanvasProperty)Mapper.obj.wz.GetObjectFromPath("Map.wz/MapHelper.img/worldMap/mapImage/1"));
  34.                     DotOrigin = ((WzVectorProperty)Dot["origin"]);
  35.                     break;
  36.                 case 2:
  37.                     Dot = ((WzCanvasProperty)Mapper.obj.wz.GetObjectFromPath("Map.wz/MapHelper.img/worldMap/mapImage/2"));
  38.                     DotOrigin = ((WzVectorProperty)Dot["origin"]); ;
  39.                     break;
  40.                 case 3:
  41.                     Dot = ((WzCanvasProperty)Mapper.obj.wz.GetObjectFromPath("Map.wz/MapHelper.img/worldMap/mapImage/3"));
  42.                     DotOrigin = ((WzVectorProperty)Dot["origin"]);
  43.                     break;
  44.             }
  45.             this.Spot = calPOS(baseOrigin, Spot);
  46.             this.type = type;
  47.             this.texture = Texture.FromBitmap(DxDevice, Dot.PngProperty.PNG, Usage.Dynamic, Pool.Default);
  48.         }
  49.  
  50.         private Point calPOS(WzVectorProperty baseOrigin, WzVectorProperty imageOrigin)
  51.         {
  52.             Point fix = new Point(baseOrigin.X.ToInt() + imageOrigin.X.ToInt() - DotOrigin.X.ToInt(), baseOrigin.Y.ToInt() + imageOrigin.Y.ToInt() - DotOrigin.Y.ToInt());
  53.             return fix;
  54.         }
  55.  
  56.         public void Update()
  57.         {
  58.             _position = Mapper.obj.pos;
  59.             Mapper.obj.Text = "Pos: " + _position.X + "/ " + _position.Y;
  60.             if (_position.X >= Spot.X && _position.X <= Spot.X + Dot.PngProperty.PNG.Width)
  61.             {
  62.                 if (_position.Y >= Spot.Y && _position.Y <= Spot.Y + Dot.PngProperty.PNG.Height)
  63.                 {
  64.                     canDraw = true;
  65.                     return;
  66.                 }
  67.             }
  68.             canDraw = false;
  69.         }
  70.  
  71.         public void StaticDraw()
  72.         {
  73.             Mapper.sprite.Draw2D(texture, new Point(0, 0), 0f, new Point(Spot.X, Spot.Y), Color.White);
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement