using System.Collections; using System.Collections.Generic; using Unity.Entities; using Unity.Mathematics; using UnityEngine; namespace HighwayRacers { public static class CommonFields { // TODO: these are READONLY for now since we are not dealing with them changing in various systems // We would need to recompute the lane tiles, respawn cars etc. public static float LANE0_LENGTH { get { return 250; } } // Length of the innermost lane. public static int NUM_LANES { get { return 4; } } public static float TILE_DIAMETER { get { return 2.0f; } } public static float LANE_SPACING { get { return 1.9f; } } public static float MID_RADIUS { get { return 31.46f; } } public static float CURVE_LANE0_RADIUS { get { return MID_RADIUS - LANE_SPACING * (NUM_LANES - 1) / 2f; } } public static float MIN_HIGHWAY_LANE0_LENGTH = CURVE_LANE0_RADIUS * 4; public static float straightPieceLength { get { return (LANE0_LENGTH - CURVE_LANE0_RADIUS * 4) / 4; } } public static float derrivedTrackRadius { get { return straightPieceLength + MID_RADIUS * 2.0f; } } public static float TrackRadius { get { return derrivedTrackRadius - LANE_SPACING * 3.0f; } } public static float LaneWidth { get { return CommonFields.LANE_SPACING * 2.0f; } } public static float RoundedCorner { get { return (1.0f - straightPieceLength / (straightPieceLength + MID_RADIUS * 2.0f)) * 0.5f; } } //public static int TilesPerLane { get { return (int)(TrackRadius / 2.0f * 4.0f); } } public static float TrackCirconference { get { return ((TrackRadius / 2.0f) * 4.0f) / 182.0f; } } public static float MinimumVelocity { get { return 0.035f / TrackCirconference; } } public static float MaximumVelocity { get { return 0.075f / TrackCirconference; } } //public static readonly bool ShowDebugTiles = false; public static float4 LowVelocityColor { get { return new float4(1, 0, 0, 1); } } //red public static float4 AmericanColors { get { return new float4(0, 1, 0, 1); } } //green public static float4 EuropeanColors { get { return new float4(0, 0, 1, 1); } } // blue public static void LogDebug() { string text = ""; text = $"LANE0_LENGTH = {LANE0_LENGTH:#.###}\n"; text += $"NUM_LANES = {NUM_LANES}\n"; text += $"LANE_SPACING={LANE_SPACING:#.###}\n"; text += $"MID_RADIUS={MID_RADIUS:#.###}\n\n"; text += $"CURVE_LANE0_RADIUS*={CURVE_LANE0_RADIUS:#.###}\n"; text += $"MIN_HIGHWAY_LANE0_LENGTH*={MIN_HIGHWAY_LANE0_LENGTH:#.###}\n"; text += $"straightPieceLength*={straightPieceLength:#.###}\n"; text += $"derrivedTrackRadius*={derrivedTrackRadius:#.###}\n"; text += $"TrackRadius*={TrackRadius:#.###}\n"; text += $"LaneWidth*={LaneWidth:#.###}\n"; text += $"RoundedCorner*={RoundedCorner:#.###}\n"; //text += $"TilesPerLane*={TilesPerLane}\n"; text += $"TrackCirconference*={TrackCirconference:#.###}\n"; text += $"MinimumVelocity*={MinimumVelocity:#.###}\n"; text += $"MaximumVelocity*={MaximumVelocity:#.###}\n"; Debug.Log(text); } } //================================================================================================ public struct LaneOccupancy : IBufferElementData { // The 8 bits in Occupied each represent one lane. // So if bit 1 is set it means lane 1 is occupied public byte Occupied; //Position } //================================================================================================ public enum DriverProfile { European = 0, American = 1, Random } }