예제 #1
0
    // Use this for initialization
    void Start()
    {
        currentScore    = GameObject.Find("CurrentScore").GetComponent <CurrentScore>();
        fullScore       = GameObject.FindObjectOfType <FullScore>();
        score           = GetComponent <Score>();
        energy          = GetComponent <Energy>();
        energyLine      = GameObject.FindObjectOfType <EnergyLine>();
        inputController = GameObject.FindObjectOfType <InputController>();
        timerScript     = GameObject.FindObjectOfType <TimerScript>();
        timerUI         = GameObject.FindObjectOfType <TimerUI>();
        info            = GetComponent <Info>();
        taskStrings     = GetComponent <TaskStrings>();
        pauseButton     = GameObject.FindObjectOfType <PauseButton>().gameObject;
        pauseMenu       = GameObject.Find("Canvas").GetComponentInChildren <PauseMenu>();
        //  endMenu = GameObject.FindObjectOfType<EndMenu>();
        taskHelper       = GameObject.FindObjectOfType <TaskHelper>();
        globalController = GetComponent <GlobalController>();
        cam            = GameObject.Find("MainCamera");
        secondCamera   = GameObject.Find("SecondCamera");
        wordRideCanvas = GameObject.FindObjectOfType <WordRideCanvas>();

        metalSparksPrefab = Resources.Load("Prefabs/Particles/MetalSpark") as GameObject;
        carUserParametres = GetComponent <CarUserParametres>();
        gameUI            = GameObject.FindObjectOfType <GameUI>();
        canvasController  = GameObject.FindObjectOfType <CanvasController>();

        particleCanvas = GameObject.Find("ParticleCanvas");
        carCreator     = GameObject.FindObjectOfType <CarCreator>();

        mainBonus = GameObject.FindObjectOfType <MainBonus>();

        waitBackground = GameObject.FindObjectOfType <WaitBackground>();
    }
예제 #2
0
    void Start()
    {
        buttonStart.SetActive(true);

        lvlChange  = FindObjectOfType <LvlChanger>();
        bus        = FindObjectOfType <Bus>();
        carCreator = FindObjectOfType <CarCreator>();
    }
예제 #3
0
    void Start()
    {
        gm         = FindObjectOfType <GameManager>();
        bus        = FindObjectOfType <Bus>();
        carCreator = FindObjectOfType <CarCreator>();

        finishPanel.SetActive(false);
    }
        // Client
        public static void Start()
        {
            Transport transport = new CarCreator();

            transport.Deliver();

            transport = new ShipCreator();
            transport.Deliver();
        }
예제 #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting 'Factory Method' Design Pattern Application!");

            // An array of creators

            VehicleCreator[] vCreators = new VehicleCreator[2];
            vCreators[0] = new BoatCreator();
            vCreators[1] = new CarCreator();

            // Iterate over creators and create products

            foreach (VehicleCreator vCreator in vCreators)
            {
                IVehicle product = vCreator.GetVehicle();
                Console.WriteLine("Created a new {0}, The mode of trnasport is {1}",
                                  product.GetType().Name, product.ModeOfTransport);
            }

            Console.ReadLine();
        }
 private static void CallCollector()
 {
     CarCreator.SpawnCollector();
 }
예제 #7
0
        public Track Best(string startP, string finishP, Type deliv, int volume)
        {
            GlobalData data   = GlobalData.GetInstance();
            int        start  = Decr(startP);
            int        finish = Decr(finishP);

            int[][] mat = new int[data.SIZE][];
            for (int i = 0; i < data.SIZE; i++)
            {
                mat[i] = new int[data.SIZE];
            }

            mat = MatrixUpd(deliv);
            int[] path = new int[data.SIZE];
            for (int i = 0; i < data.SIZE; i++)
            {
                path[i] = -1;
            }

            path = Optim(mat, start, finish);
            int count = 0;

            for (int i = 0; i < data.SIZE; i++)
            {
                if (path[i] != -1)
                {
                    count++;
                }
                else
                {
                    break;
                }
            }

            CarCreator   carCreator   = CarCreator.GetInstance();
            TrainCreator trainCreator = TrainCreator.GetInstance();
            PlaneCreator planeCreator = PlaneCreator.GetInstance();

            switch (count)
            {
            case 1:
            {
                Car car1 = carCreator.CreateTransport() as Car;
                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[0]]))
                    {
                        car1 = carCreator.CreateTransport(
                            data.tableCost[it.Value * 3 + 2],
                            data.matrixDist[path[0], path[1]])
                               as Car;
                    }
                }

                Track track = new Track();
                track.AddTransport(volume, car1);
                return(track);
            }

            case 3:
            {
                Car car1 = carCreator.CreateTransport() as Car;
                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[0]]))
                    {
                        car1 = carCreator.CreateTransport(
                            data.tableCost[it.Value * 3 + 2],
                            data.matrixDist[path[0], path[1]])
                               as Car;
                    }
                }

                Car car2 = carCreator.CreateTransport() as Car;
                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[2]]))
                    {
                        car2 = carCreator.CreateTransport(
                            data.tableCost[it.Value * 3 + 2],
                            data.matrixDist[path[2], path[3]])
                               as Car;
                    }
                }

                Train train1 = trainCreator.CreateTransport() as Train;
                Plane plane1 = planeCreator.CreateTransport() as Plane;
                Track track  = new Track();

                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[1]]) &&
                        data.points[path[1]].Contains("TS"))
                    {
                        train1 = trainCreator.CreateTransport(
                            data.tableCost[it.Value * 3 + 1],
                            data.matrixDist[path[1], path[2]])
                                 as Train;
                        track.AddTransport(volume, car1, car2, train1);
                    }

                    if (it.Key.Contains(data.points[path[1]]) &&
                        data.points[path[1]].Contains("AP"))
                    {
                        plane1 = planeCreator.CreateTransport(
                            data.tableCost[it.Value * 3],
                            data.matrixDist[path[1], path[2]])
                                 as Plane;
                        track.AddTransport(volume, car1, car2, plane1);
                    }
                }

                return(track);
            }

            case 5:
            {
                Car car1 = carCreator.CreateTransport() as Car;
                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[0]]))
                    {
                        car1 = carCreator.CreateTransport(
                            data.tableCost[it.Value * 3 + 2],
                            data.matrixDist[path[0], path[1]])
                               as Car;
                    }
                }

                Train train1 = trainCreator.CreateTransport() as Train;
                Plane plane1 = planeCreator.CreateTransport() as Plane;
                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[1]]) &&
                        data.points[path[1]].Contains("TS"))
                    {
                        train1 = trainCreator.CreateTransport(
                            data.tableCost[it.Value * 3 + 1],
                            data.matrixDist[path[1], path[2]])
                                 as Train;
                    }
                    if (it.Key.Contains(data.points[path[1]]) &&
                        data.points[path[1]].Contains("AP"))
                    {
                        plane1 = planeCreator.CreateTransport(
                            data.tableCost[it.Value * 3],
                            data.matrixDist[path[1], path[2]])
                                 as Plane;
                    }
                }

                Car car2 = carCreator.CreateTransport() as Car;
                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[2]]))
                    {
                        car2 = carCreator.CreateTransport(
                            data.tableCost[it.Value * 3 + 2],
                            data.matrixDist[path[2], path[3]])
                               as Car;
                    }
                }

                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[3]]) &&
                        data.points[path[3]].Contains("AP"))
                    {
                        plane1 = planeCreator.CreateTransport(
                            data.tableCost[it.Value * 3],
                            data.matrixDist[path[3], path[4]])
                                 as Plane;
                    }
                    if (it.Key.Contains(data.points[path[3]]) &&
                        data.points[path[3]].Contains("TS"))
                    {
                        train1 = trainCreator.CreateTransport(
                            data.tableCost[it.Value * 3 + 1],
                            data.matrixDist[path[3], path[4]])
                                 as Train;
                    }
                }

                Car car3 = carCreator.CreateTransport() as Car;
                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[4]]))
                    {
                        car3 = carCreator.CreateTransport(
                            data.tableCost[it.Value * 3 + 2],
                            data.matrixDist[path[4], path[5]])
                               as Car;
                    }
                }

                Track track = new Track();
                track.AddTransport(volume, car1, car2, car3, train1, plane1);
                return(track);
            }

            case 7:
            {
                Car car1 = carCreator.CreateTransport() as Car;
                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[0]]))
                    {
                        car1 = carCreator.CreateTransport(
                            data.tableCost[it.Value * 3 + 2],
                            data.matrixDist[path[0], path[1]])
                               as Car;
                    }
                }

                Train train1 = trainCreator.CreateTransport() as Train;
                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[1]]))
                    {
                        train1 = trainCreator.CreateTransport(
                            data.tableCost[it.Value * 3 + 1],
                            data.matrixDist[path[1], path[2]])
                                 as Train;
                    }
                }

                Car car2 = carCreator.CreateTransport() as Car;
                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[2]]))
                    {
                        car2 = carCreator.CreateTransport(
                            data.tableCost[it.Value * 3 + 2],
                            data.matrixDist[path[2], path[3]])
                               as Car;
                    }
                }

                Plane plane1 = planeCreator.CreateTransport() as Plane;
                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[3]]))
                    {
                        plane1 = planeCreator.CreateTransport(
                            data.tableCost[it.Value * 3],
                            data.matrixDist[path[3], path[4]])
                                 as Plane;
                    }
                }

                Car car3 = carCreator.CreateTransport() as Car;
                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[4]]))
                    {
                        car3 = carCreator.CreateTransport(
                            data.tableCost[it.Value * 3 + 2],
                            data.matrixDist[path[4], path[5]])
                               as Car;
                    }
                }

                Train train2 = trainCreator.CreateTransport() as Train;
                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[5]]))
                    {
                        train2 = trainCreator.CreateTransport(
                            data.tableCost[it.Value * 3 + 1],
                            data.matrixDist[path[5], path[6]])
                                 as Train;
                    }
                }

                Car car4 = carCreator.CreateTransport() as Car;
                foreach (var it in data.table)
                {
                    if (it.Key.Contains(data.points[path[6]]))
                    {
                        car4 = carCreator.CreateTransport(
                            data.tableCost[it.Value * 3 + 2],
                            data.matrixDist[path[6], path[7]])
                               as Car;
                    }
                }

                Track track = new Track();
                track.AddTransport(volume, car1, car2, car3, car4, train1, train2, plane1);

                return(track);
            }

            default:
            {
                return(null);
            }
            }
        }
예제 #8
0
파일: Library.cs 프로젝트: taboo1/arena
    // Use this for initialization
    void Start()
    {
        currentScore = GameObject.Find("CurrentScore").GetComponent<CurrentScore>();
        fullScore = GameObject.FindObjectOfType<FullScore>();
        score = GetComponent<Score>();
        energy = GetComponent<Energy>();
        energyLine = GameObject.FindObjectOfType<EnergyLine>();
        inputController = GameObject.FindObjectOfType<InputController>();
        timerScript = GameObject.FindObjectOfType<TimerScript>();
        timerUI = GameObject.FindObjectOfType<TimerUI>();
        info = GetComponent<Info>();
        taskStrings = GetComponent<TaskStrings>();
        pauseButton = GameObject.FindObjectOfType<PauseButton>().gameObject;
        pauseMenu = GameObject.Find("Canvas").GetComponentInChildren<PauseMenu>();
          //  endMenu = GameObject.FindObjectOfType<EndMenu>();
        taskHelper = GameObject.FindObjectOfType<TaskHelper>();
        globalController = GetComponent<GlobalController>();
        cam = GameObject.Find("MainCamera");
        secondCamera = GameObject.Find("SecondCamera");
        wordRideCanvas = GameObject.FindObjectOfType<WordRideCanvas>();

        metalSparksPrefab = Resources.Load("Prefabs/Particles/MetalSpark") as GameObject;
        carUserParametres = GetComponent<CarUserParametres>();
        gameUI = GameObject.FindObjectOfType<GameUI>();
        canvasController = GameObject.FindObjectOfType<CanvasController>();

        particleCanvas = GameObject.Find("ParticleCanvas");
        carCreator = GameObject.FindObjectOfType<CarCreator>();

        mainBonus = GameObject.FindObjectOfType<MainBonus>();

        waitBackground = GameObject.FindObjectOfType<WaitBackground>();
    }
        internal static void Tick(ModelingForm modelingForm, MappedTopology mappedTopology)
        {
            if (IsPaused)
            {
                return;
            }

            TimerTicksCount++;
            TicksAfterLastCarSpawning++;

            if (TimeAfterLastCarSpawningInSeconds >= TimeBetweenCars)
            {
                CarCreator.SpawnCar();
                TimeBetweenCars           = ModelSettings.TrafficFlow.TimeBetweenCars;
                TicksAfterLastCarSpawning = 0;
            }

            //if (!_paused)
            //{
            //    //return;
            //    //CarCreator.SpawnCar();
            //    CarCreator.SpawnCollector();

            //    _paused = true;
            //}


            //if (TimerTicksCount % 20 == 0)
            //{
            //    CarCreator.SpawnCar();
            //}

            #region LoopingControls

            var panelPlayground = modelingForm.PlaygroundPanel;

            foreach (Control control in panelPlayground.Controls)
            {
                if (!(control is MoveablePictureBox))
                {
                    continue;
                }

                var moveablePictureBox = control as MoveablePictureBox;

                // Car
                if (moveablePictureBox is CarPictureBox car)
                {
                    CarRouter.RouteCar(car);

                    CarMover.MoveCarToDestination(car);

                    continue;
                }

                // Collector
                if (moveablePictureBox is CollectorPictureBox collector)
                {
                    CarRouter.RouteCar(collector);

                    CarMover.MoveCarToDestination(collector);

                    continue;
                }

                // Refueller
                if (moveablePictureBox is RefuellerPictureBox refueller)
                {
                    RefuellerRouter.RouteRefueller(refueller);

                    RefuellerMover.MoveRefuellerToDestination(refueller);
                }
            }

            #endregion /LoopingControls

            #region UI

            UpdateUI(modelingForm, mappedTopology);

            #endregion UI
        }
예제 #10
0
 private void Awake()
 {
     _signCreator = GetComponent <SignsCreator>();
     _carCreator  = GetComponent <CarCreator>();
 }
예제 #11
0
파일: CarRent.cs 프로젝트: ex1mp/CarRental
 public CarRent(List <Car> carLb)
 {
     crCar   = new CarCreator();
     autoLib = new AutoLibrary(carLb);
     MainMenu();
 }
예제 #12
0
파일: CarRent.cs 프로젝트: ex1mp/CarRental
 public CarRent()
 {
     crCar   = new CarCreator();
     autoLib = new AutoLibrary();
     MainMenu();
 }
예제 #13
0
        static void CreateHyperionCars()
        {
            var carRequirements = new CarProductRequirements();

            var hyperions = new List <IHyperion> {
                new Sedan(), new Coupe(), new Sport()
            };

            foreach (var hyperion in hyperions)
            {
                switch (hyperion.GetType().Name)
                {
                case "Sedan":
                    var sedanCarCreator     = new CarCreator <SedanCreator, IHyperion, CarSpecificationDto>();
                    var sedanSpecifications = carRequirements.CreateProductSpecs(hyperion.GetType().Name, 4, 2);
                    var counter             = 0;

                    foreach (var productSpec in sedanSpecifications)
                    {
                        counter++;

                        var finishProduct = sedanCarCreator.HyperionModelCreator(productSpec);
                        ShowProduct(finishProduct, counter);
                        System.Console.WriteLine(sedanCarCreator.StartEngine("Welcome to Hyperion"));
                        System.Console.WriteLine("------------------------------------");
                        System.Console.WriteLine(Environment.NewLine);
                    }

                    break;

                case "Coupe":

                    var coupCarCreator      = new CarCreator <CoupeCreator, IHyperion, CarSpecificationDto>();
                    var coupeSpecifications = carRequirements.CreateProductSpecs(hyperion.GetType().Name, 2, 2);
                    counter = 0;

                    foreach (var productSpec in coupeSpecifications)
                    {
                        counter++;

                        var finishProduct = coupCarCreator.HyperionModelCreator(productSpec);
                        ShowProduct(finishProduct, counter);
                        System.Console.WriteLine(coupCarCreator.StartEngine("Welcome to Hyperion"));
                        System.Console.WriteLine("------------------------------------");
                        System.Console.WriteLine(Environment.NewLine);
                    }

                    break;

                case "Sport":
                    var sportCarCreator        = new CarCreator <SportCreator, IHyperion, CarSpecificationDto>();
                    var sportCarSpecifications = carRequirements.CreateProductSpecs(hyperion.GetType().Name, 20, 2, 3);
                    var counter1 = 0;

                    foreach (var productSpec in sportCarSpecifications)
                    {
                        counter1++;

                        var finishProduct = sportCarCreator.HyperionModelCreator(productSpec);
                        ShowProduct(finishProduct, counter1);
                        System.Console.WriteLine(sportCarCreator.StartEngine("Sport Mode Engaged"));
                        System.Console.WriteLine("------------------------------------");
                        System.Console.WriteLine(Environment.NewLine);
                    }
                    break;
                }
            }
        }