예제 #1
0
        public static MapPoint GlobalTilePointToLocal(MapPoint globalpoint)
        {
            Check.NullArgument (globalpoint, "localpoint");

            return globalpoint - TileEngine.WorldManager.CurrentWorld.MapList[TileEngine.CurrentMapChunk.Name].MapLocation;
        }
예제 #2
0
 public ScreenPoint(MapPoint mapPoint)
     : base((mapPoint*32).ToPoint())
 {
 }
예제 #3
0
        public static void DrawLayerMapLocal(SpriteBatch spriteBatch, MapHeader header, MapLayers layer)
        {
            Check.NullArgument (spriteBatch, "spriteBatch");
            Check.NullArgument (header, "header");

            Map currentMap = header.Map;
            ScreenPoint camOffset = TileEngine.Camera.Offset();
            ScreenPoint tileSize = currentMap.TileSize;

            for (int y = 0; y < currentMap.MapSize.Y; y++)
            {
                for (int x = 0; x < currentMap.MapSize.X; x++)
                {
                    ScreenPoint pos = new MapPoint(x, y).ToScreenPoint();
                    Rectangle des = pos.ToRect(tileSize.ToPoint());

                    Rectangle sourceRectangle = currentMap.GetLayerSourceRect(new MapPoint(x, y), layer);

                    if (sourceRectangle.IsEmpty)
                        continue;

                    spriteBatch.Draw(currentMap.Texture, des, sourceRectangle, Color.White);
                }
            }
        }
예제 #4
0
        public static Point GlobalPixelPointToLocal(MapPoint localpoint)
        {
            Check.NullArgument (localpoint, "localpoint");

            int x = localpoint.X - (TileEngine.WorldManager.CurrentWorld.MapList[TileEngine.CurrentMapChunk.Name].MapLocation.X - TileEngine.CurrentMapChunk.TileSize.X);
            int y = localpoint.Y - (TileEngine.WorldManager.CurrentWorld.MapList[TileEngine.CurrentMapChunk.Name].MapLocation.Y - TileEngine.CurrentMapChunk.TileSize.Y);

            return new Point(x, y);
        }
예제 #5
0
 public IMapEvent GetEvent(MapPoint location)
 {
     return this.events[TileEngine.CurrentMapChunk].Where(ev => ev.Rectangle.Contains(location.ToPoint())).FirstOrDefault();
 }
예제 #6
0
        // bleh
        public IMapEvent LoadEventFromXml(XmlNode node)
        {
            string type = string.Empty;
            Directions dir = Directions.Any;
            Dictionary<String, String> parameters = new Dictionary<string, string>();
            MapPoint location = new MapPoint(0, 0);
            MapPoint size = new MapPoint(0, 0);
            ActivationTypes activation = ActivationTypes.Activate;

            foreach (XmlNode cnode in node.ChildNodes)
            {
                switch (cnode.Name)
                {
                    case "Type": type = cnode.InnerText; break;
                    case "Dir": dir = (Directions)Enum.Parse(typeof(Directions), cnode.InnerText); break;
                    case "Parameters": parameters = LoadParametersFromXml(cnode); break;
                    case "Location": location = new MapPoint(cnode); break;
                    case "Size": size = new MapPoint(cnode); break;
                    case "Activation": activation = (ActivationTypes)Enum.Parse(typeof(ActivationTypes), cnode.InnerText); break;
                }
            }

            IMapEvent newEvent = this.CreateEventFromString(type); var assemblytype = Assembly.GetEntryAssembly().GetType(type);
            newEvent.Direction = dir;
            newEvent.Parameters = parameters;
            newEvent.Rectangle = new Rectangle(location.X, location.Y, size.X, size.Y);
            newEvent.Activation = activation;

            return newEvent;
        }
예제 #7
0
        public MapPoint GetLookPoint()
        {
            MapPoint point = new MapPoint(0,0);

            if (this.Direction == Directions.North)
                point = new MapPoint(0, -1);

            else if (this.Direction == Directions.South)
                point = new MapPoint(0, 1);

            else if (this.Direction == Directions.West)
                point = new MapPoint(-1, 0);

            else if (this.Direction == Directions.East)
                point = new MapPoint(1, 0);

            return point;
        }
예제 #8
0
        public int GetGlobalLayerValue(string WorldName, MapPoint globalpoint, MapLayers layer)
        {
            foreach(var header in this.WorldsList[WorldName].MapList.Values)
            {
                if(header.MapLocation.ToRect(header.Map.MapSize.ToPoint()).Contains(globalpoint.ToPoint()))
                {
                    return header.Map.GetLayerValue(header.MapLocation - globalpoint, layer);
                }
            }

            return 0;
        }
예제 #9
0
 public MapPoint(MapPoint point)
     : base(point.ToPoint())
 {
 }