// overload the constructor to properly deal with lanes that can have props public LaneData(BasicLane lane, PropManager propManager) { // store the lane position Vector3 lanePositionVector = lane.getLanePosition(); lanePosition[0] = lanePositionVector.x; lanePosition[1] = lanePositionVector.y; lanePosition[2] = lanePositionVector.z; // store the lane width and the max/min values laneWidth = lane.getLaneWidth(); maxWidth = lane.getMaxWidth(); minWidth = lane.getMinWidth(); // store the lane type laneType = lane.getLaneType(); // store the booleans vehicleLane = lane.isVehicleLane(); nonVehicleAsphalt = lane.isNonVehicleAsphaltLane(); nonAsphalt = lane.isNonAsphaltLane(); // store the stripes' data GameObject leftStripe = lane.getStripe("left"); GameObject rightStripe = lane.getStripe("right"); if (leftStripe != null) { Stripe leftStripeScriptRef = (Stripe)leftStripe.GetComponent("Stripe"); leftStripeData = new StripeData(leftStripeScriptRef); } if (rightStripe != null) { Stripe rightStripeScriptRef = (Stripe)rightStripe.GetComponent("Stripe"); rightStripeData = new StripeData(rightStripeScriptRef); } propManagerData = new PropManagerData(propManager); }
public void loadProps(PropManagerData savedPropManager) { // walk through props and add them List <PropData> savedPropData = savedPropManager.getPropData(); foreach (PropData propData in savedPropData) { // insert new prop based on propData float correctZValue = GetComponent <BasicLane>().getLanePosition().z + propData.loadZValueOffsetFromLane(); Vector3 newPropPosition = new Vector3(propData.loadXPosition(), propData.loadYPosition(), correctZValue); CurrentPropManager.Instance.setRotation(propData.loadRotation()); GameObject newProp = addProp(Resources.Load(propData.loadPropType()), newPropPosition); newProp.GetComponent <Prop>().loadPropData(propData); } CurrentPropManager.Instance.setRotation(0); }