Esempio n. 1
0
        private static string[] SerializeCarGenerator(CarGenerator carGen)
        {
            string[] data = new string[NumColumns];
            data[0]  = ((uint)carGen.Model).ToString();
            data[1]  = carGen.Location.X.ToString();
            data[2]  = carGen.Location.Y.ToString();
            data[3]  = carGen.Location.Z.ToString();
            data[4]  = carGen.Heading.ToString();
            data[5]  = carGen.Color1.ToString();
            data[6]  = carGen.Color2.ToString();
            data[7]  = carGen.ForceSpawn.ToString();
            data[8]  = carGen.AlarmChance.ToString();
            data[9]  = carGen.LockedChance.ToString();
            data[10] = carGen.MinSpawnDelay.ToString();
            data[11] = carGen.MaxSpawnDelay.ToString();
            data[12] = carGen.Timer.ToString();
            data[13] = carGen.Unknown24.ToString();
            data[14] = carGen.HasRecentlyBeenStolen.ToString();
            data[15] = carGen.SpawnCount.ToString();
            data[16] = carGen.Unknown2C.ToString();
            data[17] = carGen.Unknown30.ToString();
            data[18] = carGen.Unknown34.ToString();
            data[19] = carGen.Unknown38.ToString();
            data[20] = carGen.Unknown3C.ToString();
            data[21] = carGen.Unknown40.ToString();
            data[22] = carGen.Unknown44.ToString();

            return(data);
        }
Esempio n. 2
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        CarGenerator map = target as CarGenerator;

        map.GenerateMap();
    }
Esempio n. 3
0
 public void SetRotation(Quaternion newrot, Quaternion oldrot, bool editPivot)
 {
     if (EntityDef != null)
     {
         if (editPivot)
         {
             EntityDef.SetPivotOrientationFromWidget(newrot);
         }
         else
         {
             EntityDef.SetOrientationFromWidget(newrot);
         }
     }
     else if (CarGenerator != null)
     {
         CarGenerator.SetOrientation(newrot);
     }
     else if (ScenarioNode != null)
     {
         ScenarioNode.SetOrientation(newrot);
     }
     else if (NavPoint != null)
     {
         NavPoint.SetOrientation(newrot);
     }
     else if (NavPortal != null)
     {
         NavPortal.SetOrientation(newrot);
     }
     else if (Audio != null)
     {
         Audio.SetOrientation(newrot);
     }
 }
Esempio n. 4
0
 public void SetScale(Vector3 newscale, bool editPivot)
 {
     if (MultipleSelectionItems != null)
     {
         if (editPivot)
         {//editing pivot scale is sort of meaningless..
         }
         else
         {
             var cen   = MultipleSelectionCenter;
             var ori   = MultipleSelectionRotation;
             var orinv = Quaternion.Invert(ori);
             var rsca  = newscale / MultipleSelectionScale;
             for (int i = 0; i < MultipleSelectionItems.Length; i++)
             {
                 if (MultipleSelectionItems[i].CollisionPoly == null)//skip polys, they use gathered verts
                 {
                     var refpos = MultipleSelectionItems[i].WidgetPosition;
                     var relpos = refpos - cen;
                     var newpos = ori.Multiply(orinv.Multiply(relpos) * rsca) + cen;
                     MultipleSelectionItems[i].SetPosition(newpos, false);
                     MultipleSelectionItems[i].SetScale(newscale, false);
                 }
             }
             if (GatheredCollisionVerts != null)
             {
                 for (int i = 0; i < GatheredCollisionVerts.Length; i++)
                 {
                     var refpos = GatheredCollisionVerts[i].Position;
                     var relpos = refpos - cen;
                     var newpos = ori.Multiply(orinv.Multiply(relpos) * rsca) + cen;
                     GatheredCollisionVerts[i].Position = newpos;
                 }
             }
             MultipleSelectionScale = newscale;
         }
     }
     else if (EntityDef != null)
     {
         EntityDef.SetScale(newscale);
     }
     else if (CarGenerator != null)
     {
         CarGenerator.SetScale(newscale);
         AABB = new BoundingBox(CarGenerator.BBMin, CarGenerator.BBMax);
     }
     else if (CollisionVertex != null)
     {
         //do nothing, but stop any poly from being scaled also
     }
     else if (CollisionPoly != null)
     {
         CollisionPoly.Scale = newscale;
     }
     else if (CollisionBounds != null)
     {
         CollisionBounds.Scale = newscale;
     }
 }
Esempio n. 5
0
 public void SetPosition(Vector3 newpos, bool editPivot)
 {
     if (MultipleSelection)
     {
         //don't do anything here for multiselection
     }
     else if (EntityDef != null)
     {
         if (editPivot)
         {
             EntityDef.SetPivotPositionFromWidget(newpos);
         }
         else
         {
             EntityDef.SetPositionFromWidget(newpos);
         }
     }
     else if (CarGenerator != null)
     {
         CarGenerator.SetPosition(newpos);
     }
     else if (PathNode != null)
     {
         PathNode.SetPosition(newpos);
     }
     else if (CollisionPoly != null)
     {
         CollisionPoly.Position = newpos;
     }
     else if (CollisionBounds != null)
     {
         CollisionBounds.Position = newpos;
     }
     else if (NavPoly != null)
     {
         NavPoly.SetPosition(newpos);
     }
     else if (NavPoint != null)
     {
         NavPoint.SetPosition(newpos);
     }
     else if (NavPortal != null)
     {
         NavPortal.SetPosition(newpos);
     }
     else if (TrainTrackNode != null)
     {
         TrainTrackNode.SetPosition(newpos);
     }
     else if (ScenarioNode != null)
     {
         ScenarioNode.SetPosition(newpos);
     }
     else if (Audio != null)
     {
         Audio.SetPosition(newpos);
     }
 }
 public static void onClickRide()
 {
     if (UserSelector.selectedNode != null)
     {
         // to stop the cars.. set the speed of each car to zero.
         CarGenerator.stopCars();
         isRiding = true;
     }
 }
Esempio n. 7
0
        public void SetPosition(Vector3 newpos, bool editPivot)
        {
            if (MultipleSelection)
            {
                //don't do anything here for multiselection
            }
            else if (EntityDef != null)
            {
                if (editPivot)
                {
                    EntityDef.SetPivotPositionFromWidget(newpos);
                }
                else
                {
                    EntityDef.SetPositionFromWidget(newpos);
                }
            }
            else if (CarGenerator != null)
            {
                CarGenerator.SetPosition(newpos);
            }
            else if (PathNode != null)
            {
                PathNode.SetPosition(newpos);
            }
            else if (NavPoly != null)
            {
                NavPoly.SetPosition(newpos);

                //if (projectForm != null)
                //{
                //    projectForm.OnWorldNavPolyModified(NavPoly);
                //}
            }
            else if (NavPoint != null)
            {
                NavPoint.SetPosition(newpos);
            }
            else if (NavPortal != null)
            {
                NavPortal.SetPosition(newpos);
            }
            else if (TrainTrackNode != null)
            {
                TrainTrackNode.SetPosition(newpos);
            }
            else if (ScenarioNode != null)
            {
                ScenarioNode.SetPosition(newpos);
            }
            else if (Audio != null)
            {
                Audio.SetPosition(newpos);
            }
        }
Esempio n. 8
0
 public void SetScale(Vector3 newscale, Vector3 oldscale, bool editPivot)
 {
     if (EntityDef != null)
     {
         EntityDef.SetScale(newscale);
     }
     else if (CarGenerator != null)
     {
         CarGenerator.SetScale(newscale);
         AABB = new BoundingBox(CarGenerator.BBMin, CarGenerator.BBMax);
     }
 }
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        flame = transform.Find("Flames").GetComponent<ParticleEmitter>();
        smoke = transform.Find("Smoke").GetComponent<ParticleEmitter>();
        enableToMove = false;
        transform.position = new Vector3(189, 33, 116);
        Invoke("startToPlay", 2.0F);

        motoGenerator = GameObject.FindGameObjectWithTag("motoGenerator").GetComponent<MotorcycleGenerator>();
        carGenerator = GameObject.FindGameObjectWithTag("carGenerator").GetComponent<CarGenerator>();
        truckGenerator = GameObject.FindGameObjectWithTag("truckGenerator").GetComponent<TruckGenerator>();
    }
Esempio n. 10
0
    // Use this for initialization
    void Start()
    {
        flame              = transform.Find("Flames").GetComponent <ParticleEmitter>();
        smoke              = transform.Find("Smoke").GetComponent <ParticleEmitter>();
        enableToMove       = false;
        transform.position = new Vector3(189, 33, 116);
        Invoke("startToPlay", 2.0F);

        motoGenerator  = GameObject.FindGameObjectWithTag("motoGenerator").GetComponent <MotorcycleGenerator>();
        carGenerator   = GameObject.FindGameObjectWithTag("carGenerator").GetComponent <CarGenerator>();
        truckGenerator = GameObject.FindGameObjectWithTag("truckGenerator").GetComponent <TruckGenerator>();
    }
 public override void OnInspectorGUI()
 {
     base.OnInspectorGUI();
     if (GUILayout.Button("Generate"))
     {
         CarGenerator generator = (CarGenerator)serializedObject.targetObject;
         foreach (RoadNode roadNode in FindObjectsOfType <RoadNode>())
         {
             if (generator.chancePerNode > Random.value)
             {
                 GameObject prefab = generator.prefabs[Random.Range(0, generator.prefabs.Length)];
                 GameObject clone  = Instantiate(prefab,
                                                 roadNode.transform.position, Quaternion.identity, generator.root);
             }
         }
     }
 }
Esempio n. 12
0
        public IActionResult Get()
        {
            var car = new Car();
            var rng = new Random();

            car.Brand          = CarGenerator.GenerateBrand(rng.Next(0, 5));
            car.Model          = CarGenerator.GenerateModel(car.Brand, rng.Next(0, 6));
            car.ProductionYear = rng.Next(1990, 2020);
            car.Mileage        = rng.Next(0, 300000).ToString();
            car.FuelType       = CarGenerator.GenerateFuelType(rng.Next(0, 3));
            car.Engine         = rng.Next(1, 3).ToString() + "." + rng.Next(0, 10).ToString();
            car.Power          = rng.Next(90, 300).ToString();
            car.Price          = rng.Next(10000, 200000);
            car.Description    = "Auto bez żadnej rdzy !!!  Silnik suchy bez wycieków , sprzęgło ) i skrzynia biegów pracują precyzyjnie bez zarzutów . Auto bardzoczyste i zadbane. . .Auto gotowe do eksploatacji bez wkładu finansowego UWAGA !!!!!!!!!!!!!! AUTO GOTOWE DO REJESTRACJI !!! UWAGA !!!!";


            return(Ok(car));
        }
Esempio n. 13
0
    // 0 = no Simulation
    // 1 = Euclidean
    // 2 = Ant Colony
    // 3 = MPAC


    //GameObject EuclideanCar = null;
    //GameObject AntCar = null;
    //GameObject MPACCar = null;


    // Use this for initialization
    void Start()
    {
        nodeCount     = nodeGrid * nodeGrid;
        algoEuclidean = gameObject.GetComponent <Euclidean> ();
        algoAntColony = gameObject.GetComponent <AntColonyController> ();
        algoMPAC      = gameObject.GetComponent <MPAC> ();

        userSelector = gameObject.GetComponent <UserSelector> ();
        carGenerator = gameObject.GetComponent <CarGenerator> ();
        // create the under laying surface
        GameObject surface;

        surface = GameObject.CreatePrimitive(PrimitiveType.Quad);
        surface.transform.Rotate(new Vector3(90, 0, 0));
        surface.transform.localScale = new Vector3(2 * boundry, 2 * boundry, 1);
        surface.GetComponent <MeshRenderer> ().material = groundMat;
        GenerateGraph();
        isMapGenerated = true;

        resetButton.onClick.AddListener(onClickReset);


        btnEuclidean.onClick.AddListener(onClickEuclidean);
        btnAntColony.onClick.AddListener(onClickAntColony);
        btnMPAC.onClick.AddListener(onClickMPAC);
        sliderAntSpeed.onValueChanged.AddListener(onSliderValueChange);
        sliderPheremoneEvaporate.onValueChanged.AddListener(onPheremoneSliderValueChange);
        btnRefresh.onClick.AddListener(onRefreshButton);
        toggleHideAnts.onValueChanged.AddListener((value) => { onToggleHideAnts(); });


        toggleGenderPref.onValueChanged.AddListener((value) => { onToggleGenderPref(value); });
        toggleAgePref.onValueChanged.AddListener((value) => { onToggleAgePref(value); });
        Gender_Male.onValueChanged.AddListener((value) => { onToggleGenderMale(value); });
        Gender_Female.onValueChanged.AddListener((value) => { onToggleGenderFemale(value); });

        Age_30.onValueChanged.AddListener((value) => { onToggleAge30(value); firstAgeCall = true; });
        Age_49.onValueChanged.AddListener((value) => { onToggleAge49(value); firstAgeCall = true; });
        Age_50.onValueChanged.AddListener((value) => { onToggleAge50(value); firstAgeCall = true; });

        SaveButton.onClick.AddListener(onClickSave);

        carGenerator.Generate(carCount);
    }
Esempio n. 14
0
        /// <summary>
        /// Creates an array of <see cref="CarGenerator"/>s from the
        /// specified CSV file.
        /// </summary>
        /// <param name="path">The path to the CSV file.</param>
        /// <returns>
        /// An array of car generators created with the data from the
        /// CSV file.
        /// </returns>
        /// <exception cref="InvalidDataException">
        /// Thrown if the CSV data is formatted incorrectly.
        /// </exception>
        public static CarGenerator[] Read(string path)
        {
            List <CarGenerator> loadedCarGenerators = new List <CarGenerator>();

            using (TextFieldParser parser = new TextFieldParser(path)) {
                // Define tokens and delimiters
                parser.CommentTokens = new string[] { "#" };
                parser.SetDelimiters(new string[] { "," });

                // Skip first line with column names
                parser.ReadFields();

                // Read car generators
                while (!parser.EndOfData)
                {
                    string[]     fields = parser.ReadFields();
                    CarGenerator carGen = CreateCarGenerator(fields);
                    loadedCarGenerators.Add(carGen);
                }
            }

            return(loadedCarGenerators.ToArray());
        }
Esempio n. 15
0
 // Use this for initialization
 void Start()
 {
     motoGenerator = GameObject.FindGameObjectWithTag("motoGenerator").GetComponent<MotorcycleGenerator>();
     carGenerator = GameObject.FindGameObjectWithTag("carGenerator").GetComponent<CarGenerator>();
     truckGenerator = GameObject.FindGameObjectWithTag("truckGenerator").GetComponent<TruckGenerator>();
 }
Esempio n. 16
0
 public CarTests(ApiApplicationFactory <Startup> factory, CarGenerator carGenerator)
 {
     client            = factory.CreateTestClient("cars/");
     this.carGenerator = carGenerator;
 }
Esempio n. 17
0
        public string GetFullNameString(string defval)
        {
            string name = defval;

            if (MultipleSelection)
            {
                name = "Multiple items";
            }
            else if (EntityDef != null)
            {
                name = EntityDef._CEntityDef.archetypeName.ToString();
            }
            else if (Archetype != null)
            {
                name = Archetype.Hash.ToString();
            }
            else if (CollisionBounds != null)
            {
                name = CollisionBounds.GetName();
            }
            if (Geometry != null)
            {
                name += " (" + GeometryIndex.ToString() + ")";
            }
            if (TimeCycleModifier != null)
            {
                name = TimeCycleModifier.CTimeCycleModifier.name.ToString();
            }
            if (BoxOccluder != null)
            {
                name = "BoxOccluder " + (BoxOccluder.Ymap?.Name ?? "") + ": " + BoxOccluder.Index.ToString();
            }
            if (OccludeModel != null)
            {
                name = "OccludeModel " + (OccludeModel.Ymap?.Name ?? "") + ": " + OccludeModel.Index.ToString();
            }
            if (CarGenerator != null)
            {
                name = CarGenerator.NameString();
            }
            if (EntityExtension != null)
            {
                name += ": " + EntityExtension.Name;
            }
            if (ArchetypeExtension != null)
            {
                name += ": " + ArchetypeExtension.Name;
            }
            if (WaterQuad != null)
            {
                name = "WaterQuad " + WaterQuad.ToString();
            }
            if (NavPoly != null)
            {
                name = "NavPoly " + NavPoly.ToString();
            }
            if (NavPoint != null)
            {
                name = "NavPoint " + NavPoint.ToString();
            }
            if (NavPortal != null)
            {
                name = "NavPortal " + NavPortal.ToString();
            }
            if (PathNode != null)
            {
                name = "PathNode " + PathNode.AreaID.ToString() + "." + PathNode.NodeID.ToString();// + FloatUtil.GetVector3String(PathNode.Position);
            }
            if (TrainTrackNode != null)
            {
                name = "TrainTrackNode " + FloatUtil.GetVector3String(TrainTrackNode.Position);
            }
            if (ScenarioNode != null)
            {
                name = ScenarioNode.ToString();
            }
            if (Audio != null)
            {
                name = Audio.ShortTypeName + " " + Audio.GetNameString();//  + FloatUtil.GetVector3String(Audio.InnerPos);
            }
            if (MloRoomDef != null)
            {
                name = "MloRoomDef " + MloRoomDef.RoomName;
            }
            return(name);
        }
Esempio n. 18
0
 public void SetRotation(Quaternion newrot, bool editPivot)
 {
     if (MultipleSelectionItems != null)
     {
         if (editPivot)
         {
         }
         else
         {
             var cen   = MultipleSelectionCenter;
             var orinv = Quaternion.Invert(MultipleSelectionRotation);
             var trans = newrot * orinv;
             for (int i = 0; i < MultipleSelectionItems.Length; i++)
             {
                 if (MultipleSelectionItems[i].CollisionPoly == null)//skip polys, they use gathered verts
                 {
                     var refpos = MultipleSelectionItems[i].WidgetPosition;
                     var relpos = refpos - cen;
                     var newpos = trans.Multiply(relpos) + cen;
                     var refori = MultipleSelectionItems[i].WidgetRotation;
                     var newori = trans * refori;
                     MultipleSelectionItems[i].SetPosition(newpos, false);
                     MultipleSelectionItems[i].SetRotation(newori, false);
                 }
             }
             if (GatheredCollisionVerts != null)
             {
                 for (int i = 0; i < GatheredCollisionVerts.Length; i++)
                 {
                     var refpos = GatheredCollisionVerts[i].Position;
                     var relpos = refpos - cen;
                     var newpos = trans.Multiply(relpos) + cen;
                     GatheredCollisionVerts[i].Position = newpos;
                 }
             }
             MultipleSelectionRotation = newrot;
         }
     }
     else if (EntityDef != null)
     {
         if (editPivot)
         {
             EntityDef.SetPivotOrientationFromWidget(newrot);
         }
         else
         {
             EntityDef.SetOrientationFromWidget(newrot);
         }
     }
     else if (CarGenerator != null)
     {
         CarGenerator.SetOrientation(newrot);
     }
     else if (CollisionVertex != null)
     {
         //do nothing, but stop any poly from being rotated also
     }
     else if (CollisionPoly != null)
     {
         CollisionPoly.Orientation = newrot;
     }
     else if (CollisionBounds != null)
     {
         CollisionBounds.Orientation = newrot;
     }
     else if (ScenarioNode != null)
     {
         ScenarioNode.SetOrientation(newrot);
     }
     else if (NavPoint != null)
     {
         NavPoint.SetOrientation(newrot);
     }
     else if (NavPortal != null)
     {
         NavPortal.SetOrientation(newrot);
     }
     else if (Audio != null)
     {
         Audio.SetOrientation(newrot);
     }
 }
Esempio n. 19
0
 public void SetPosition(Vector3 newpos, bool editPivot)
 {
     if (MultipleSelectionItems != null)
     {
         if (editPivot)
         {
         }
         else
         {
             var dpos = newpos - MultipleSelectionCenter;// oldpos;
             if (dpos == Vector3.Zero)
             {
                 return;                       //nothing moved.. (probably due to snap)
             }
             for (int i = 0; i < MultipleSelectionItems.Length; i++)
             {
                 if (MultipleSelectionItems[i].CollisionPoly == null)//skip polys, they use gathered verts
                 {
                     var refpos = MultipleSelectionItems[i].WidgetPosition;
                     MultipleSelectionItems[i].SetPosition(refpos + dpos, false);
                 }
             }
             if (GatheredCollisionVerts != null)
             {
                 for (int i = 0; i < GatheredCollisionVerts.Length; i++)
                 {
                     var refpos = GatheredCollisionVerts[i].Position;
                     GatheredCollisionVerts[i].Position = refpos + dpos;
                 }
             }
             MultipleSelectionCenter = newpos;
         }
     }
     else if (EntityDef != null)
     {
         if (editPivot)
         {
             EntityDef.SetPivotPositionFromWidget(newpos);
         }
         else
         {
             EntityDef.SetPositionFromWidget(newpos);
         }
     }
     else if (CarGenerator != null)
     {
         CarGenerator.SetPosition(newpos);
     }
     else if (PathNode != null)
     {
         PathNode.SetPosition(newpos);
     }
     else if (CollisionVertex != null)
     {
         CollisionVertex.Position = newpos;
     }
     else if (CollisionPoly != null)
     {
         CollisionPoly.Position = newpos;
     }
     else if (CollisionBounds != null)
     {
         CollisionBounds.Position = newpos;
     }
     else if (NavPoly != null)
     {
         NavPoly.SetPosition(newpos);
     }
     else if (NavPoint != null)
     {
         NavPoint.SetPosition(newpos);
     }
     else if (NavPortal != null)
     {
         NavPortal.SetPosition(newpos);
     }
     else if (TrainTrackNode != null)
     {
         TrainTrackNode.SetPosition(newpos);
     }
     else if (ScenarioNode != null)
     {
         ScenarioNode.SetPosition(newpos);
     }
     else if (Audio != null)
     {
         Audio.SetPosition(newpos);
     }
 }
Esempio n. 20
0
 void Start()
 {
     player       = GameObject.FindWithTag("Player");
     carGenerator = GameObject.FindWithTag("CarGenerator").GetComponent <CarGenerator>();
     parkedCars   = GameObject.FindWithTag("CustomerGenerator").GetComponent <ParkedCars>();
 }
Esempio n. 21
0
 private void OnEnable()
 {
     m_carGenerator = target as CarGenerator;
 }
Esempio n. 22
0
 void Start()
 {
     carGenerator = GameObject.FindWithTag("CarGenerator").GetComponent <CarGenerator>();
     slider.value = 1;
 }
Esempio n. 23
0
 // Use this for initialization
 void Start()
 {
     motoGenerator  = GameObject.FindGameObjectWithTag("motoGenerator").GetComponent <MotorcycleGenerator>();
     carGenerator   = GameObject.FindGameObjectWithTag("carGenerator").GetComponent <CarGenerator>();
     truckGenerator = GameObject.FindGameObjectWithTag("truckGenerator").GetComponent <TruckGenerator>();
 }
 private void Awake()
 {
     generator = GetComponent <CarGenerator>();
     Invoke("Init", 2);
 }