示例#1
0
        public void CreateCar()
        {
            VehicleBuilder vehicleBuilder = new CarBuilder();

            VehicleDirector.Construct(vehicleBuilder, "v8", "4", "4");
            vehicleBuilder.Vehicle.ShowVehicle();
        }
    void Start()
    {
        VehicleBuilderBase carBuilder  = new CarBuilder();
        VehicleBuilderBase bikeBuilder = new BikeBuilder();

        vehicleDirector.Construct(carBuilder);
        vehicleDirector.Construct(bikeBuilder);

        Vehicle carInfo  = carBuilder.GetVehicle();
        Vehicle bikeInfo = bikeBuilder.GetVehicle();


        Debug.Log(carInfo.VehicleName + " got " + carInfo.VehicleParts.Count + " parts");
        Debug.Log(bikeInfo.VehicleName + " got " + bikeInfo.VehicleParts.Count + " parts");
    }