示例#1
0
 public TrackHistory(int x, int y, TrackGenerator.TrackSlope slope)
 {
     this.X     = (short)x;
     this.Y     = (short)y;
     this.Slope = slope;
     this.Mode  = TrackGenerator.TrackMode.Normal;
 }
示例#2
0
        private void RewriteSlopeDirection(int index, TrackGenerator.TrackSlope slope)
        {
            int num = (int)(slope - this._history[index].Slope);

            this._history[index].Slope = slope;
            for (int index1 = index; index1 < this._length; ++index1)
            {
                this._history[index1].Y += (short)num;
            }
        }
示例#3
0
        private TrackGenerator.TrackPlacementState CreateTunnel()
        {
            TrackGenerator.TrackSlope trackSlope1 = TrackGenerator.TrackSlope.Straight;
            int num = 10;

            TrackGenerator.TrackPlacementState trackPlacementState1 = TrackGenerator.TrackPlacementState.Invalid;
            int x = (int)this._history[this._length - 1].X;
            int y = (int)this._history[this._length - 1].Y;

            for (TrackGenerator.TrackSlope trackSlope2 = TrackGenerator.TrackSlope.Up; trackSlope2 <= TrackGenerator.TrackSlope.Down; ++trackSlope2)
            {
                TrackGenerator.TrackPlacementState trackPlacementState2 = TrackGenerator.TrackPlacementState.Invalid;
                for (int index = 1; index < num; ++index)
                {
                    trackPlacementState2 = TrackGenerator.CalculateStateForLocation(x + index * this._xDirection, y + index * (int)trackSlope2);
                    switch (trackPlacementState2)
                    {
                    case TrackGenerator.TrackPlacementState.Obstructed:
                        continue;

                    case TrackGenerator.TrackPlacementState.Invalid:
                        goto label_6;

                    default:
                        trackSlope1          = trackSlope2;
                        num                  = index;
                        trackPlacementState1 = trackPlacementState2;
                        goto label_6;
                    }
                }
label_6:
                if (trackPlacementState1 != TrackGenerator.TrackPlacementState.Available && trackPlacementState2 == TrackGenerator.TrackPlacementState.Obstructed && (trackPlacementState1 != TrackGenerator.TrackPlacementState.Obstructed || trackSlope1 != TrackGenerator.TrackSlope.Straight))
                {
                    trackSlope1          = trackSlope2;
                    num                  = 10;
                    trackPlacementState1 = trackPlacementState2;
                }
            }
            if (this._length == 0 || !TrackGenerator.CanSlopesTouch(this._history[this._length - 1].Slope, trackSlope1))
            {
                this.RewriteSlopeDirection(this._length - 1, TrackGenerator.TrackSlope.Straight);
            }
            this._history[this._length - 1].Mode = TrackGenerator.TrackMode.Tunnel;
            for (int index = 1; index < num; ++index)
            {
                this.AppendToHistory(trackSlope1, TrackGenerator.TrackMode.Tunnel);
            }
            return(trackPlacementState1);
        }
示例#4
0
 private static bool CanSlopesTouch(
     TrackGenerator.TrackSlope leftSlope,
     TrackGenerator.TrackSlope rightSlope)
 {
     return(leftSlope == rightSlope || leftSlope == TrackGenerator.TrackSlope.Straight || rightSlope == TrackGenerator.TrackSlope.Straight);
 }
示例#5
0
 private void AppendToHistory(TrackGenerator.TrackSlope slope, TrackGenerator.TrackMode mode = TrackGenerator.TrackMode.Normal)
 {
     this._history[this._length]      = new TrackGenerator.TrackHistory((int)this._history[this._length - 1].X + this._xDirection, (int)((sbyte)this._history[this._length - 1].Y + slope), slope);
     this._history[this._length].Mode = mode;
     ++this._length;
 }