예제 #1
0
        public MapShape AddVisitedItem(IMultiTileShape shape)
        {
            if (VisitedShapes.Contains(shape))
            {
                return(null);
            }
            else
            {
                Point position = new Point(shape.Rect.Location.X * Constants.TilePx / Scale.X, shape.Rect.Location.Y * Constants.TilePx / Scale.Y);
                Size  size     = new Size(shape.Rect.Size.Width * Constants.TilePx / Scale.X, shape.Rect.Size.Height * Constants.TilePx / Scale.Y);
                //position = new Point(position.X + Engine.MapWindow.Canvas_MiniMap.Margin.Left,position.Y +Engine.MapWindow.Canvas_MiniMap.Margin.Top);

                Rect     rectangle = new Rect(position, size);
                MapShape t         = new MapShape((Vector)position, size, shape is RoomModule ? MapShape.TypeEnum.Room : MapShape.TypeEnum.Road);
                Tiles.Add(t);
                VisitedShapes.Add(shape);

                if (shape is RoomModule)
                {
                    RoomModule s = (RoomModule)shape;
                    s.Roads.ForEach(road => AddVisitedItem(road));
                }

                return(t);
            }
        }
예제 #2
0
        /*public void AddTile( Vector Position, Tile.TypeEnum type,MultiTileShape multiTileShape)
         * {
         *  Tile t = new Tile(Position,multiTileShape, type);
         *  //t.InitialiseRect();
         *  if (this.Tiles.ContainsKey(t.Position)) return;
         *
         *  this.Tiles.Add(t.Position, t);
         *
         *  if (t.Type == Tile.TypeEnum.Wall)
         *  {
         *      this.WallTiles.Add(t);
         *  }
         * }*/

        public Vector CalculateAngle(RoomModule roomModule)
        {
            List <Vector> Positions = new List <Vector>
            {
                new Vector(roomModule.Rect.X, roomModule.Rect.Y),
                new Vector(roomModule.Rect.X + roomModule.Rect.Width, roomModule.Rect.Y),
                new Vector(roomModule.Rect.X, roomModule.Rect.Y + roomModule.Rect.Height),
                new Vector(roomModule.Rect.X + roomModule.Rect.Width, roomModule.Rect.Y + roomModule.Rect.Height)
            };

            List <double> Angles = new List <double>();

            Positions.ForEach(pos =>
            {
                double angle = Vector.AngleBetween((Vector)this.Rect.Location, pos);
                Angles.Add(angle);
            });


            return(new Vector(Angles.Min(), Angles.Max()));
        }