コード例 #1
0
 public void updateNode(TrackNode node)
 {
     allowedDirections = new List <string>();
     allowedDirections.Add("   ");
     allowedDirections.Add("In");
     allowedDirections.Add("Out");
     allowedDirections.Add("Both");
     //DirBuffer = AllowedDir.NONE;
     if (NameBuffer != null && NameBuffer.Length > 0 && DirBuffer != AllowedDir.NONE)
     {
         Configured = true;
     }
     else
     {
         Configured = false;
     }
     typeItem      = (int)TypeItem.BUFFER_ITEM;
     associateNode = node;
     //associateNodeIdx = (int)componentItem.Index;
     associateSectionIdx = 0;
     Coord        = new MSTSCoord(node);
     Location.X   = associateNode.UiD.TileX * 2048f + associateNode.UiD.X;
     Location.Y   = associateNode.UiD.TileZ * 2048f + associateNode.UiD.Z;
     node.Reduced = true;
 }
コード例 #2
0
ファイル: AESegment.cs プロジェクト: pzgulyas/openrails-1
        public AESegment(TrVectorSection item1, TrVectorSection item2)
        {
            MSTSCoord A = new MSTSCoord(item1);
            MSTSCoord B = new MSTSCoord(item2);

            startPoint = A.ConvertToPointF();
            endPoint   = B.ConvertToPointF();
        }
コード例 #3
0
ファイル: MSTSCoord.cs プロジェクト: pzgulyas/openrails-1
 public MSTSCoord(MSTSCoord coord)
 {
     TileX   = coord.TileX;
     TileY   = coord.TileY;
     X       = coord.X;
     Y       = coord.Y;
     Reduced = coord.Reduced;
 }
コード例 #4
0
        //  Used only in RunActivity
        public StationItem SearchByLocation(WorldLocation location)
        {
            MSTSCoord          place       = new MSTSCoord(location);
            List <StationItem> listStation = GetStationItem();

            foreach (var item in listStation)
            {
                if (item.IsInStation(place))
                {
                    return(item);
                }
            }
            return(null);
        }
コード例 #5
0
ファイル: GlobalItem.cs プロジェクト: xiaomailong/OpenRails
        }                                                       // Never save this information, it comes from MSTS

        /// <summary>
        /// The default constructor
        /// </summary>
        public GlobalItem()
        {
            movable    = false;
            rotable    = false;
            editable   = false;
            lineSnap   = false;
            actEdit    = false;
            isSeen     = false;
            asMetadata = false;
            typeItem   = (int)TypeItem.GLOBAL_ITEM;
            Location   = new PointF(float.NegativeInfinity, float.NegativeInfinity);
            Location2D = new PointF(float.NegativeInfinity, float.NegativeInfinity);
            Coord      = new MSTSCoord();
        }
コード例 #6
0
ファイル: MSTSCoord.cs プロジェクト: pzgulyas/openrails-1
        public static bool near(MSTSCoord x, MSTSCoord y)
        {
            float squareA = (float)Math.Pow((x.X - y.X), 2);
            float squareB = (float)Math.Pow((x.Y - y.Y), 2);
            float AX      = (float)Math.Round((Decimal)(x.X - y.Y), 2, MidpointRounding.ToEven);
            float AY      = (float)Math.Round((Decimal)x.Y, 2, MidpointRounding.ToEven);
            float BX      = (float)Math.Round((Decimal)y.X, 2, MidpointRounding.ToEven);
            float BY      = (float)Math.Round((Decimal)y.Y, 2, MidpointRounding.ToEven);

            if ((float)Math.Round((Decimal)(squareA + squareB)) < 0.1f && x.TileX == y.TileX && x.TileY == y.TileY)
            {
                return(true);
            }
            return(false);
        }
コード例 #7
0
ファイル: MSTSCoord.cs プロジェクト: pzgulyas/openrails-1
        // Equality operator. test if the coordinates are at the same point.
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (GetType() != obj.GetType())
            {
                return(false);
            }

            MSTSCoord other = (MSTSCoord)obj;

            return(this.X == other.X && this.Y == other.Y && this.TileX == other.TileX && this.TileY == other.TileY);
        }
コード例 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sideItem"></param>
 /// <param name="signal"></param>
 public AEBufferItem(TrackNode item)
 {
     allowedDirections = new List <string>();
     allowedDirections.Add("   ");
     allowedDirections.Add("In");
     allowedDirections.Add("Out");
     allowedDirections.Add("Both");
     DirBuffer           = AllowedDir.NONE;
     Configured          = false;
     typeItem            = (int)TypeItem.BUFFER_ITEM;
     associateNode       = item;
     associateNodeIdx    = (int)item.Index;
     associateSectionIdx = 0;
     Coord      = new MSTSCoord(item);
     Location.X = associateNode.UiD.TileX * 2048f + associateNode.UiD.X;
     Location.Y = associateNode.UiD.TileZ * 2048f + associateNode.UiD.Z;
 }
コード例 #9
0
ファイル: TrackNodeAE.cs プロジェクト: xiaomailong/OpenRails
        /// <summary>
        /// Permet de récupérer les coordonnées du node au format MSTSCoord propre à l'éditeur d'activité
        /// Return the MSTSCoord for the current node as needed by Activity Editor
        ///     For vectorNode with multiple section, the direction is used to give the first encountered section
        /// </summary>
        public static MSTSCoord getMSTSCoord(this TrackNode node, int direction)
        {
            MSTSCoord coord = new MSTSCoord();

            if (node.TrEndNode || node.TrJunctionNode != null || node.TrVectorNode.TrVectorSections == null)
            {
                coord.TileX = node.UiD.TileX;
                coord.TileY = node.UiD.TileZ;
                coord.X     = node.UiD.X;
                coord.Y     = node.UiD.Z;
            }
            else if (node.TrVectorNode != null && node.TrVectorNode.TrVectorSections.Length > 1)
            {
                if (direction == 0)
                {
                    TrVectorSection section = node.TrVectorNode.TrVectorSections.Last();
                    coord.TileX = section.TileX;
                    coord.TileY = section.TileZ;
                    coord.X     = section.X;
                    coord.Y     = section.Z;
                }
                else
                {
                    TrVectorSection section = node.TrVectorNode.TrVectorSections.First();
                    coord.TileX = section.TileX;
                    coord.TileY = section.TileZ;
                    coord.X     = section.X;
                    coord.Y     = section.Z;
                }
            }
            else if (node.TrVectorNode != null)
            {
                coord.TileX = node.TrVectorNode.TrVectorSections[0].TileX;
                coord.TileY = node.TrVectorNode.TrVectorSections[0].TileZ;
                coord.X     = node.TrVectorNode.TrVectorSections[0].X;
                coord.Y     = node.TrVectorNode.TrVectorSections[0].Z;
            }
            return(coord);
        }
コード例 #10
0
ファイル: AESegment.cs プロジェクト: pzgulyas/openrails-1
 public AESegment(MSTSCoord start, MSTSCoord end)
 {
     startPoint    = start.ConvertToPointF();
     endPoint      = end.ConvertToPointF();
     lengthSegment = 0;
 }
コード例 #11
0
ファイル: AESegment.cs プロジェクト: pzgulyas/openrails-1
        public MSTSCoord getEnd()
        {
            MSTSCoord point = new MSTSCoord(startPoint);

            return(point);
        }
コード例 #12
0
ファイル: AESegment.cs プロジェクト: pzgulyas/openrails-1
        public Vector2 getEndPoint()
        {
            MSTSCoord info = new MSTSCoord(endPoint);

            return(info.ConvertVector2());
        }
コード例 #13
0
ファイル: AESegment.cs プロジェクト: pzgulyas/openrails-1
        public Vector2 getStartPoint()
        {
            MSTSCoord info = new MSTSCoord(startPoint);

            return(info.ConvertVector2());
        }
コード例 #14
0
ファイル: MSTSCoord.cs プロジェクト: pzgulyas/openrails-1
        public MSTSCoord getMstsCoord(PointF point)
        {
            MSTSCoord coord = new MSTSCoord(point);

            return(coord);
        }
コード例 #15
0
ファイル: GlobalItem.cs プロジェクト: xiaomailong/OpenRails
 public virtual void configCoord(MSTSCoord coord)
 {
     Coord      = new MSTSCoord(coord);
     Location.X = coord.TileX * 2048f + coord.X;
     Location.Y = coord.TileY * 2048f + coord.Y;
 }
コード例 #16
0
ファイル: GlobalItem.cs プロジェクト: xiaomailong/OpenRails
 public virtual void Update(MSTSCoord coord)
 {
 }