Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.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.             //this.Spot = new Point(Spot.X.ToInt(), Spot.Y.ToInt());
  27.             switch (type)
  28.             {
  29.                 case 0:
  30.                     Dot = ((WzCanvasProperty)Mapper.obj.wz.GetObjectFromPath("Map.wz/MapHelper.img/worldMap/mapImage/0"));
  31.                     DotOrigin = ((WzVectorProperty)Dot["origin"]);
  32.                     break;
  33.                 case 1:
  34.                     Dot = ((WzCanvasProperty)Mapper.obj.wz.GetObjectFromPath("Map.wz/MapHelper.img/worldMap/mapImage/1"));
  35.                     DotOrigin = ((WzVectorProperty)Dot["origin"]);
  36.                     break;
  37.                 case 2:
  38.                     Dot = ((WzCanvasProperty)Mapper.obj.wz.GetObjectFromPath("Map.wz/MapHelper.img/worldMap/mapImage/2"));
  39.                     DotOrigin = ((WzVectorProperty)Dot["origin"]); ;
  40.                     break;
  41.                 case 3:
  42.                     Dot = ((WzCanvasProperty)Mapper.obj.wz.GetObjectFromPath("Map.wz/MapHelper.img/worldMap/mapImage/3"));
  43.                     DotOrigin = ((WzVectorProperty)Dot["origin"]);
  44.                     break;
  45.             }
  46.             this.Spot = calPOS(baseOrigin, Spot);
  47.             this.type = type;
  48.             this.texture = Texture.FromBitmap(DxDevice, Dot.PngProperty.PNG, Usage.Dynamic, Pool.Default);
  49.         }
  50.  
  51.         public MapList(Microsoft.DirectX.Direct3D.Device DxDevice, Microsoft.DirectX.DirectInput.Device mouse, string desc, string name, int type, WzVectorProperty Spot, WzVectorProperty baseOrigin)
  52.         {
  53.             this.desc = desc;
  54.             this.Name = name;
  55.             this.Mouse = mouse;
  56.             switch (type)
  57.             {
  58.                 case 0:
  59.                     Dot = ((WzCanvasProperty)Mapper.obj.wz.GetObjectFromPath("Map.wz/MapHelper.img/worldMap/mapImage/0"));
  60.                     DotOrigin = ((WzVectorProperty)Dot["origin"]);
  61.                     break;
  62.                 case 1:
  63.                     Dot = ((WzCanvasProperty)Mapper.obj.wz.GetObjectFromPath("Map.wz/MapHelper.img/worldMap/mapImage/1"));
  64.                     DotOrigin = ((WzVectorProperty)Dot["origin"]);
  65.                     break;
  66.                 case 2:
  67.                     Dot = ((WzCanvasProperty)Mapper.obj.wz.GetObjectFromPath("Map.wz/MapHelper.img/worldMap/mapImage/2"));
  68.                     DotOrigin = ((WzVectorProperty)Dot["origin"]); ;
  69.                     break;
  70.                 case 3:
  71.                     Dot = ((WzCanvasProperty)Mapper.obj.wz.GetObjectFromPath("Map.wz/MapHelper.img/worldMap/mapImage/3"));
  72.                     DotOrigin = ((WzVectorProperty)Dot["origin"]);
  73.                     break;
  74.             }
  75.             this.type = type;
  76.             this.Spot = calPOS(baseOrigin,Spot);
  77.             //this.Spot = new Point(Spot.X.ToInt(), Spot.Y.ToInt());
  78.             this.texture = Texture.FromBitmap(DxDevice, Dot.PngProperty.PNG, Usage.Dynamic, Pool.Default);
  79.         }
  80.  
  81.         private Point calPOS(WzVectorProperty baseOrigin, WzVectorProperty imageOrigin)
  82.         {
  83.             Point fix = new Point(baseOrigin.X.ToInt() + imageOrigin.X.ToInt() - DotOrigin.X.ToInt(), baseOrigin.Y.ToInt() + imageOrigin.Y.ToInt() - DotOrigin.Y.ToInt());
  84.             return fix;
  85.         }
  86.  
  87.         public void Update()
  88.         {
  89.             //still invalid mouse pos
  90.             _position = Mapper.obj.pos;
  91.             Mapper.obj.Text = "Pos: " + _position.X + "/ " + _position.Y;
  92.             byte[] buttons = Mouse.CurrentMouseState.GetMouseButtons();
  93.             if (0 != buttons[0])
  94.             {
  95.                 if (canDraw == true)
  96.                 {
  97.                     //Mapper.obj.test.Text = linkMap;
  98.                 }
  99.             }
  100.             else
  101.             {
  102.             }
  103.  
  104.             if (_position.X >= Spot.X && _position.X <= Spot.X + Dot.PngProperty.PNG.Width)
  105.             {
  106.                 if (_position.Y >= Spot.Y && _position.Y <= Spot.Y + Dot.PngProperty.PNG.Height)
  107.                 {
  108.                     canDraw = true;
  109.                     return;
  110.                 }
  111.             }
  112.             canDraw = false;
  113.         }
  114.  
  115.         public void StaticDraw()
  116.         {
  117.             Mapper.sprite.Draw2D(texture, new Point(0, 0), 0f, new Point(Spot.X, Spot.Y), Color.White);
  118.         }
  119.     }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement