Exemplo n.º 1
0
 private static bool FindSuitableOrigin(ref Point origin)
 {
     TrackGenerator.TrackPlacementState stateForLocation;
     while ((stateForLocation = TrackGenerator.CalculateStateForLocation(origin.X, origin.Y)) != TrackGenerator.TrackPlacementState.Obstructed)
     {
         ++origin.Y;
         if (stateForLocation == TrackGenerator.TrackPlacementState.Invalid)
         {
             return(false);
         }
     }
     --origin.Y;
     return(TrackGenerator.CalculateStateForLocation(origin.X, origin.Y) == TrackGenerator.TrackPlacementState.Available);
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        private TrackGenerator.TrackPlacementState GetHistorySegmentPlacementState(
            int startIndex,
            int length)
        {
            TrackGenerator.TrackPlacementState trackPlacementState = TrackGenerator.TrackPlacementState.Available;
            for (int index = startIndex; index < startIndex + length; ++index)
            {
                TrackGenerator.TrackPlacementState stateForLocation = TrackGenerator.CalculateStateForLocation((int)this._history[index].X, (int)this._history[index].Y);
                switch (stateForLocation)
                {
                case TrackGenerator.TrackPlacementState.Obstructed:
                    if (this._history[index].Mode != TrackGenerator.TrackMode.Tunnel)
                    {
                        trackPlacementState = stateForLocation;
                        break;
                    }
                    break;

                case TrackGenerator.TrackPlacementState.Invalid:
                    return(stateForLocation);
                }
            }
            return(trackPlacementState);
        }