示例#1
0
    public void TestPark()
    {
        if (Random.Range(0.0f, 100.0f) < parkChance_)
        {
            Road         road    = car_.GetCurRoad().GetComponent <Road>();
            ParkingSpace parking = null;
            if (road)
            {
                GameObject space = road.GetParkingSpace();
                if (space)
                {
                    parking = space.GetComponent <ParkingSpace>();
                }
            }

            if (parking)
            {
                car_.SetState(CarState.CS_PARKING);
                parking.SetAvailable(false);

                car_.ClearTargets();
                List <Vector3> newTargets = parking.GetEnterTargets();
                foreach (Vector3 target in newTargets)
                {
                    car_.AddTarget(target);
                }

                curParking_ = parking;
            }
        }
    }