Exemple #1
0
    // 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);
    }
Exemple #2
0
    // Nathan wrote this
    // loads a saved lane's data
    public void loadLaneAtts(LaneData savedLane)
    {
        // just need to reassign each of the lane's attributes (position, width, stripes, etc.)
        // not sure we need position (the lanes will be inserted either way, and should all be
        // the correct type and in the correct order without resetting this)
        // also not sure we need to set type, max/min width, or the booleans
        // as these should all be set properly by inserting the saved lane type
        // the only true variables are the width and the stripes
        setLaneWidth(savedLane.loadLaneWidth());
        // stripes could be a little more complicated
        // first, load in the data for both stripes

        StripeData leftStripeData  = savedLane.loadStripeData("left");
        StripeData rightStripeData = savedLane.loadStripeData("right");

        // if the stripes are not null, load in their data
        // otherwise, just set their orientation to null
        if (leftStripeData != null)
        {
            // subcase: not sure if we need it, but just in case
            if (leftStripe != null)
            {
                Stripe leftStripeScriptReference = (Stripe)leftStripe.GetComponent("Stripe");
                leftStripeScriptReference.loadStripeAtts(leftStripeData);
            }
            else
            {
                Debug.Log("This almost certainly should never happen. INSIDE WEIRD LOADING CASE.");
            }
        }
        else
        {
            setStripeOrientation(null, "left");
        }
        if (rightStripeData != null)
        {
            // again, not sure we need this subcase
            if (rightStripe != null)
            {
                Stripe rightStripeScriptReference = (Stripe)rightStripe.GetComponent("Stripe");
                rightStripeScriptReference.loadStripeAtts(rightStripeData);
            }
            else
            {
                Debug.Log("This almost certainly should never happen. INSIDE WEIRD LOADING CASE.");
            }
        }
        else
        {
            setStripeOrientation(null, "right");
        }
    }
Exemple #3
0
 // Nathan wrote this
 // loads a saved stripe's data
 public void loadStripeAtts(StripeData savedStripe)
 {
     // for now, we just need to set the stripe's saved type
     setStripeType(savedStripe.loadStripeType(), gameObject.transform.position);
 }