public StageSegment FirstStageSegment(int x, int y) { StageSegment first_stage_segment = CreateStageSegment(x, y, SegmentType.Flat, 0); m_stagemanager.StageSegments.Add(first_stage_segment); return(first_stage_segment); }
public void PlaceRoadSegments(int start_x, int start_y, int stage_num) { m_stagemanager.StageSegments.Clear(); int x = start_x; int y = start_y; StageSegment previous_segment = FirstStageSegment(start_x, start_y); List <SegmentType> stage = m_stages_to_generate[stage_num]; for (int i = 0; i < stage.Count; i++) { AddStageSegment(ref previous_segment, stage[i]); } /* * AddStageSegment(ref previous_segment, SegmentType.Flat); * AddStageSegment(ref previous_segment, SegmentType.Flat); * AddStageSegment(ref previous_segment, SegmentType.Up5); * AddStageSegment(ref previous_segment, SegmentType.Up10); * AddStageSegment(ref previous_segment, SegmentType.Up10); * AddStageSegment(ref previous_segment, SegmentType.Up5); * AddStageSegment(ref previous_segment, SegmentType.Flat); * AddStageSegment(ref previous_segment, SegmentType.Flat); * AddStageSegment(ref previous_segment, SegmentType.Up5); * AddStageSegment(ref previous_segment, SegmentType.Flat); * AddStageSegment(ref previous_segment, SegmentType.Down5); * AddStageSegment(ref previous_segment, SegmentType.Down10); * AddStageSegment(ref previous_segment, SegmentType.Down10); * AddStageSegment(ref previous_segment, SegmentType.Down5); * AddStageSegment(ref previous_segment, SegmentType.Flat); * AddStageSegment(ref previous_segment, SegmentType.Flat); * AddStageSegment(ref previous_segment, SegmentType.Up10); * AddStageSegment(ref previous_segment, SegmentType.Flat); * AddStageSegment(ref previous_segment, SegmentType.Flat); * AddStageSegment(ref previous_segment, SegmentType.Down10); * AddStageSegment(ref previous_segment, SegmentType.Down10); * AddStageSegment(ref previous_segment, SegmentType.Flat); * AddStageSegment(ref previous_segment, SegmentType.Flat); * AddStageSegment(ref previous_segment, SegmentType.Flat); * AddStageSegment(ref previous_segment, SegmentType.Flat); * AddStageSegment(ref previous_segment, SegmentType.Up5); * AddStageSegment(ref previous_segment, SegmentType.Up10); * AddStageSegment(ref previous_segment, SegmentType.Up10); * AddStageSegment(ref previous_segment, SegmentType.Up5); * AddStageSegment(ref previous_segment, SegmentType.Up5); * AddStageSegment(ref previous_segment, SegmentType.Up10); * AddStageSegment(ref previous_segment, SegmentType.Up10); * AddStageSegment(ref previous_segment, SegmentType.Up5); * AddStageSegment(ref previous_segment, SegmentType.Flat);*/ m_stagemanager.StageTotalLength = (int)previous_segment.Position.X + m_stagemanager.RoadWidth; }
public StageSegment CreateStageSegment(float x, float y, SegmentType segment_type, float corrector) { Texture2D texture = m_road_textures[(int)segment_type]; Texture2D scenery_texture = null; Texture2D[] scenery_texture_array = m_scenery_textures[(int)segment_type]; if (scenery_texture_array != null) { scenery_texture = scenery_texture_array[0]; } StageSegment new_segment = new StageSegment(new Vector2(x, y - texture.Height), texture, scenery_texture, segment_type, corrector); return(new_segment); }
public void AddStageSegment(ref StageSegment previous_segment, SegmentType new_segment_type) { float x = previous_segment.Position.X + m_stagemanager.RoadWidth; float y = previous_segment.Position.Y; Vector2 slope_increase = (Vector2)((Hashtable)m_slope_height_increase_dict[previous_segment.SegmentType])[new_segment_type]; y -= slope_increase.X + slope_increase.Y; StageSegment new_stage_segment = CreateStageSegment(x, y, new_segment_type, slope_increase.Y); m_stagemanager.StageSegments.Add(new_stage_segment); previous_segment = new_stage_segment; }
public StagePositionInformation InfoAt(float x) { StagePositionInformation info_object = new StagePositionInformation(); x = -x; StageSegment target_segment = null; for (int i = (int)Math.Floor(x / RoadWidth); i < m_stage_segments.Count; i++) { if (m_stage_segments[i].Position.X <= x && m_stage_segments[i].Position.X + RoadWidth >= x) { target_segment = m_stage_segments[i]; break; } } if (target_segment == null) { Console.WriteLine("ERROR: InfoAt(" + x + ") - Could not find target segment."); info_object.valid = false; return(info_object); } float start_y = target_segment.TopLeftPosition.Y; float target_y = start_y; switch (target_segment.SegmentType) { case SegmentType.Down5: case SegmentType.Down10: start_y = target_segment.TopLeftPosition.Y + target_segment.Corrector; target_y = target_segment.BottomRightPosition.Y - RoadHeight; break; case SegmentType.Up5: case SegmentType.Up10: start_y = target_segment.Position.Y - RoadHeight + target_segment.Corrector; target_y = target_segment.TopRightPosition.Y; break; } info_object.valid = true; info_object.stage_segment = target_segment; info_object.height = -MathHelper.Lerp(start_y, target_y, (x - target_segment.TopLeftPosition.X) / RoadWidth); return(info_object); }