public bool canBeBuilt(Location loc)
        {
            TrafficVoxel voxel = TrafficVoxel.get(loc);

            if (voxel == null)
            {
                return(false);
            }

            RailRoad rr = voxel.railRoad;

            if (rr == null)
            {
                return(false);
            }

            RailPattern rp = rr.getPattern();

            if (rp.numberOfRails != 2)
            {
                return(false);
            }

            if (!rp.hasRail(rr.dir1.opposite))
            {
                return(false);
            }

            return(rr.dir1.isSharp);
        }
示例#2
0
        public override void drawVoxel(QuarterViewDrawer view, DrawContextEx canvas, Location loc, Point pt)
        {
            if (base.currentPos != loc)
            {
                return;
            }
            if (!contribution.canBeBuilt(loc))
            {
                return;
            }

            int         x;
            RailPattern rp = TrafficVoxel.get(loc).railRoad.getPattern();

            if (rp.hasRail(Direction.NORTH))
            {
                x = 1;
            }
            else
            {
                x = 0;
            }

            contribution.sprites[x, 0].drawAlpha(canvas.surface, pt);
            contribution.sprites[x, 1].drawAlpha(canvas.surface, pt);
        }
        /// <summary>
        /// Create a new electric pole at the specified location.
        /// </summary>
        /// <param name="loc"></param>
        public void create(Location loc)
        {
            Debug.Assert(canBeBuilt(loc));

            int         x;
            RailPattern rp = TrafficVoxel.get(loc).railRoad.getPattern();

            if (rp.hasRail(Direction.NORTH))
            {
                x = 1;
            }
            else
            {
                x = 0;
            }

            new ElectricPole(TrafficVoxel.get(loc), this, x);
        }
示例#4
0
        /// <summary>
        /// Check if this voxel should have a rail road crossing.
        /// </summary>
        /// <returns></returns>
        private bool shouldHaveCrossing()
        {
            if (_railRoad == null || _road == null)
            {
                return(false);
            }

            RailPattern rp    = _railRoad.getPattern();
            Direction   rdir1 = _railRoad.dir1;

            if (rp.numberOfRails != 2 || !rp.hasRail(rdir1.opposite))
            {
                return(false);                  // the rail must be going straight.
            }
            if (!rdir1.isSharp)
            {
                return(false);                  // rail must be paralell to X-axis or Y-axis.
            }
            if (!_road.hasRoad(rdir1.left90) || !_road.hasRoad(rdir1.right90))
            {
                return(false);                  // road must be orthogonal to rail road
            }
            return(true);
        }