Example #1
0
        public Vehicle(string vehicleRego, VehicleClass vehicleClass, string make,
                       string model, int year, int numSeats, TransmissionType transmissionType,
                       FuelType fuelType, bool GPS, bool sunRoof, double dailyRate, string colour)
        {
            //private variables
            _vehicleRego      = vehicleRego;
            _vehicleClass     = vehicleClass;
            _make             = make;
            _model            = model;
            _year             = year;
            _numSeats         = numSeats;
            _transmissionType = transmissionType;
            _fuelType         = fuelType;
            _GPS           = GPS;
            _sunRoof       = sunRoof;
            _dailyRate     = dailyRate;
            _colour        = colour;
            vehicleRegoPub = vehicleRego;
            _GPSat         = GPS;
            _sunRoofat     = sunRoof;

            //getters/setters
            _VehicleRego      = vehicleRego;
            _VehicleClass     = vehicleClass;
            _Make             = make;
            _Model            = model;
            _Year             = year;
            _NumSeats         = numSeats;
            _Transmissiontype = transmissionType;
            _FuelType         = fuelType;
            _gps       = GPS;
            _SunRoof   = sunRoof;
            _DailyRate = dailyRate;
            _Colour    = colour;
        }
Example #2
0
    void DockShip(VehicleClass _vehicle)
    {
        dockedShips.Add(_vehicle);

        if (dockedShips.Count == 1)
        {
            SelectShipTab(_vehicle);
            editorFromShopButton.SetActive(true);
        }

        helpResourcesText.gameObject.SetActive(false);
        bool isNew = true;

        foreach (ShipSelector sellector in shipSelectors)
        {
            if (sellector.Vehicle == _vehicle)
            {
                sellector.gameObject.SetActive(true);
                isNew = false;
                break;
            }
        }
        if (isNew)
        {
            AddShipSelector(_vehicle);
            shipEditor.CreateShipEditor(_vehicle);
        }
        else
        {
            shipEditor.RefreshTabs();
        }
    }
Example #3
0
 public VehicleTest(int id, VehicleClass vc, string mk, string md, string eng, int wh, int dr, int vt)
 {
     Id               = id;
     VehicleClass     = vc;
     Image            = vc.ToString();
     VehicleClassType = vc.ToString();
     Make             = mk;
     Model            = md;
     Engine           = eng;
     Wheels           = wh;
     Doors            = dr;
     VehicleType      = vt;
     this.Name        = mk + " - " + md + " - " + eng;
     if (vt == (int)CarType.Sedan)
     {
         this.Name += " (Sedan)";
     }
     else if (vt == (int)CarType.HatchBack)
     {
         this.Name += " (Hatch)";
     }
     else if (vt == (int)BikeType.Road)
     {
         this.Name += " (Road Bike)";
     }
     else if (vt == (int)BikeType.OffRoad)
     {
         this.Name += " (Off-Road Bike)";
     }
 }
Example #4
0
        private static void CreateDictionary()
        {
            int runs = 0;

            dict = new Dictionary <VehicleClass, List <VehicleHash> >();
            foreach (VehicleHash vehicleHash in Enum.GetValues(typeof(VehicleHash)))
            {
                runs++;
                //Debug.WriteLine("Runs " + runs);

                Model        model    = new Model(vehicleHash);
                VehicleClass vehClass = Vehicle.GetModelClass(model);
                //Debug.WriteLine("line 31" + vehicleHash.ToString());
                if (dict.TryGetValue(vehClass, out List <VehicleHash> list))
                {
                    //Debug.WriteLine("line 34");
                    if (list.Contains(vehicleHash))
                    {
                        //Debug.WriteLine("Tried to add existing " + vehicleHash.ToString() + " to existing list of " + vehClass.ToString());
                        continue;
                    }
                    //Debug.WriteLine("Added " + vehicleHash.ToString() + " to existing list of " + vehClass.ToString());
                    list.Add(vehicleHash);
                }
                else
                {
                    //Debug.WriteLine("line 45");
                    var newList = new List <VehicleHash>();
                    newList.Add(vehicleHash);
                    dict.Add(vehClass, newList);
                    //Debug.WriteLine("Added " + vehicleHash.ToString() + " to new list of " + vehClass.ToString());
                }
            }
        }
Example #5
0
    void UndockShip(VehicleClass _vehicle)
    {
        dockedShips.Remove(_vehicle);
        foreach (ShipSelector selector in shipSelectors)
        {
            if (selectedVehicle == _vehicle)
            {
                selectedVehicle = null;
            }

            if (selector.Vehicle == _vehicle)
            {
                selector.gameObject.SetActive(false);
                DisableResourceList();
            }
        }
        if (dockedShips.Count <= 0)
        {
            currentCapacityText.text = "0";
            maxCapacityText.text     = "0";
            helpResourcesText.gameObject.SetActive(true);
            editorFromShopButton.SetActive(false);
            shipEditor.CloseTab();
        }
        else
        {
            //shipEditor.RefreshTabs();
            SelectShipTab(dockedShips[0]);
            if (shipEditor.ActiveShip == _vehicle)
            {
                shipEditor.GoToShipEditor(dockedShips[0]);
            }
        }
    }
Example #6
0
    public void InstallPart(VehicleClass _vehicle)
    {
        switch (partType)
        {
        case PartType.Drill:
            _vehicle.InstallPart((PartDrill)installedPart);
            break;

        case PartType.Cabin:
            _vehicle.InstallPart((PartCabin)installedPart);
            break;

        case PartType.Engine:
            _vehicle.InstallPart((PartEngine)installedPart);
            break;

        case PartType.Wheels:
            _vehicle.InstallPart((PartWheel)installedPart);
            break;

        case PartType.Upgrade:
            _vehicle.InstallPart((PartUpgrade)installedPart);
            break;
        }
    }
Example #7
0
        public VehicleModel(string model, int makeId, VehicleClass vClass)
        {
            VehicleClass = vClass;
            MakeId       = makeId;

            Model = model;
        }
Example #8
0
 public CarshopVehicleModel(string name, VehicleHash hash, VehicleClass category, decimal cost, CarshopType type)
 {
     Name         = name;
     Hash         = hash;
     Category     = category;
     Cost         = cost;
     CarshopTypes = type;
 }
Example #9
0
 public int GetDropdownValue(Dropdown dropdown)
 {
     print("dropdown changed");
     dropdownChosen    = dropdown.value;
     vehicleToTransfer = vehiclesToTrade[dropdown.value];
     RefreshTradeInventory();
     return(dropdown.value);
 }
Example #10
0
 public void GoToShipEditor(int index)
 {
     editorTabs[openEditorIndex].transform.gameObject.SetActive(false);
     editorTabs[index].transform.gameObject.SetActive(true);
     editorTabs[index].RefreshComponents();
     helpText.gameObject.SetActive(false);
     openEditorIndex = index;
     selectedShip    = editorTabs[index].vehicle;
 }
Example #11
0
    void AddShipSelector(VehicleClass _vehicle)
    {
        GameObject   newSelector = Instantiate(shipSelectorPrefab, dockedShipsGroup.transform);
        ShipSelector selector    = newSelector.GetComponent <ShipSelector>();

        selector.Vehicle = _vehicle;
        selector.Shop    = this;
        shipSelectors.Add(selector);
    }
        public void AddVehicleToCarshop(Client sender, VehicleHash hash, VehicleClass vehicleClass, decimal cost, string type, string type2 = "Empty")
        {
            if (!sender.HasRank(ServerRank.AdministratorRozgrywki2))
            {
                sender.SendWarning("Nie posiadasz uprawnień do tworzenia pojazdu w salonie.");
                return;
            }

            if (Vehicles.Any(v => v.Hash == hash))
            {
                sender.SendError("Podany pojazd jest już dodany.");
                return;
            }

            MoneyValidator validator = new MoneyValidator();

            if (!validator.IsValid(cost))
            {
                sender.SendError("Wprowadzona kwota gotówki jest nieprawidłowa.");
                return;
            }

            CarshopType endType      = CarshopType.Empty;
            CarshopType endType2     = CarshopType.Empty;
            var         carshopTypes = ((CarshopType[])Enum.GetValues(typeof(CarshopType))).ToList();

            if (carshopTypes.All(carshopType => carshopType.GetDescription() != type && carshopType.GetDescription() != type2))
            {
                sender.SendError("Wprowadzony typ salonu jest nieprawidłowy.");
            }

            foreach (CarshopType item in carshopTypes)
            {
                if (item.GetDescription() == type)
                {
                    endType = item;
                }
                if (item.GetDescription() == type2)
                {
                    endType2 = item;
                }
            }

            if (endType2 != CarshopType.Empty)
            {
                endType = endType | endType2;
            }

            CarshopVehicleModel vehicle =
                new CarshopVehicleModel(hash.ToString(), hash, vehicleClass, cost, endType)
            {
                CreatorForumName = sender.GetAccountEntity().DbModel.Name
            };

            XmlHelper.AddXmlObject(vehicle, Path.Combine(Utils.XmlDirectory, "CarshopVehicles"), vehicle.Name);
        }
        private async void Main()
        {
            List <VehicleClass> vehClassesWithoutCruiseControl = new List <VehicleClass>
            {
                VehicleClass.Cycles,
                VehicleClass.Motorcycles,
                VehicleClass.Planes,
                VehicleClass.Helicopters,
                VehicleClass.Boats,
                VehicleClass.Trains
            };

            while (true)
            {
                await Delay(0);

                if (LocalVehicle == null)
                {
                    continue;
                }
                _vehClass    = LocalVehicle.ClassType;
                _cruiseSpeed = LocalVehicle.Speed;

                if (LocalVehicle.IsInWater || !LocalVehicle.IsEngineRunning || LocalVehicle.Driver != LocalPed || LocalPed.IsDead || LocalVehicle.IsInAir || LocalVehicle.HasCollided ||
                    LocalVehicle.SteeringScale >= 0.675f || LocalVehicle.SteeringScale <= -0.675f || IsKeyJustPressed(InputGroups.S, Controls.S) || _cruiseSpeed * 2.23694 + 0.5 < 20 ||
                    _cruiseSpeed * 2.23694 + 0.5 > 150 || vehClassesWithoutCruiseControl.IndexOf(_vehClass) != -1 || HasTireBurst(LocalVehicle, 0) || HasTireBurst(LocalVehicle, 1) ||
                    HasTireBurst(LocalVehicle, 2) || HasTireBurst(LocalVehicle, 3) || HasTireBurst(LocalVehicle, 4) || HasTireBurst(LocalVehicle, 5) || HasTireBurst(LocalVehicle, 45) ||
                    HasTireBurst(LocalVehicle, 47) || IsKeyJustPressed(InputGroups.HANDBRAKE, Controls.HANDBRAKE) || LocalVehicle.CurrentGear == 0)
                {
                    _cruiseControl = false;
                    continue;
                }

                if (API.IsDisabledControlJustPressed(0, _toggleCruiseControlKey) ||
                    IsKeyJustPressed(InputGroups.CONTROLLER_DPAD_UP, Controls.CONRTOLLER_DPAD_UP) &&
                    IsKeyJustPressed(InputGroups.CONTROLLER_X, Controls.CONTROLLER_X))
                {
                    if (!_cruiseControl)
                    {
                        Debug.Write($"[TOASTYSCRUISECONTROL] - KEYBIND: { _toggleCruiseControlKey }.");
                        SetSpeed();
                        _cruiseControl = true;
                    }
                    else
                    {
                        _cruiseControl = false;
                    }
                }

                if (_cruiseControl && IsKeyPressed(InputGroups.W, Controls.W))
                {
                    _cruiseControl = false;
                    AcceleratingToNewSpeed();
                }
            }
        }
Example #14
0
 public static List <VehicleHash> GetVehsForVehicleClass(VehicleClass vehicleClass)
 {
     if (dict != null && dict.TryGetValue(vehicleClass, out List <VehicleHash> vehicleList))
     {
         return(vehicleList);
     }
     CreateDictionary();
     dict.TryGetValue(vehicleClass, out List <VehicleHash> vehList);
     return(vehList);
 }
Example #15
0
 public Car_O(int _carNum, string _brand, string _model, string _year, string _color, State _status, VehicleClass _class)
 {
     CarNum = _carNum;
     Brand  = _brand;
     Model  = _model;
     Year   = _year;
     Color  = _color;
     Status = _status;
     Class  = _class;
 }
Example #16
0
    public void RefreshUI(VehicleClass vehicle)
    {
        shipName.text = vehicle.ShipName;

        UpdateParts(vehicle);

        UpdateWorkers(vehicle);

        RefreshInventoryUI(vehicle);
    }
Example #17
0
 public bool IsDocked(VehicleClass _vehicle)
 {
     foreach (VehicleClass _dockedShip in dockedShips)
     {
         if (_vehicle == _dockedShip)
         {
             return(true);
         }
     }
     return(false);
 }
Example #18
0
 public void CancelSelectedTargets()
 {
     foreach (Transform _vehicle in playerShips)
     {
         VehicleClass _vehicleClass = _vehicle.GetComponent <VehicleClass>();
         if (_vehicleClass.Selected)
         {
             _vehicleClass.MovementScript.ClearPath();
         }
     }
 }
Example #19
0
 public void EnableTrade(VehicleClass baseVehicle, VehicleClass[] tradingVehicles)
 {
     referenceVehicle = baseVehicle;
     vehiclesToTrade  = tradingVehicles;
     tradeMenu.SetActive(true);
     disableTradeButton.SetActive(true);
     selfInvMenu.SetActive(true);
     PopulateDropdown(tradeOptionsDropdown, tradingVehicles);
     vehicleToTransfer = vehiclesToTrade[0];
     RefreshTradeInventory();
     RefreshTradeInventory();
 }
Example #20
0
 public static VehicleHash GetRandomVehicleByClass(VehicleClass vClass)
 {
     VehicleHash[] hashes = Enum.GetValues(typeof(VehicleHash)) as VehicleHash[];
     if (hashes != null)
     {
         hashes = (from h in hashes
                   where VehicleExtended.GetModelClass(h) == vClass
                   select h).ToArray();
         return(hashes[Random.Next(hashes.Length)]);
     }
     return(GTA.Native.VehicleHash.ZType);
 }
Example #21
0
        public void cmd_V(Client player, string input)
        {
            string[] param = input.Split(null);

            if (param[0] == "lista")
            {
                Dictionary <int, int> vehicles = VehicleClass.ListPlayerVehicles(player);
                if (vehicles.Count > 0)
                {
                    string json = API.toJson(vehicles);
                    API.triggerClientEvent(player, "vehicle_select", json);
                }
                else
                {
                    API.sendNotificationToPlayer(player, "Nie posiadasz żadnego pojazdu.");
                    return;
                }
            }
            if (param[0] == "zamknij" || param[0] == "z")
            {
                NetHandle vehicle = VehicleClass.GetNearestVehicle(player.position, 5f);

                if (!VehicleClass.IsPlayerHasPermForVehicle(player, vehicle))
                {
                    API.sendNotificationToPlayer(player, "Nie jesteś właścicielem tego pojazdu.");
                    return;
                }

                bool lk = !API.getVehicleLocked(vehicle);
                API.setVehicleLocked(vehicle, lk);
                API.sendNotificationToPlayer(player, (lk ? "Zamknąłeś" : "Otworzyłeś") + " pojazd!");
            }
            if (param[0] == "zaparkuj")
            {
                if (!API.isPlayerInAnyVehicle(player))
                {
                    API.sendNotificationToPlayer(player, "Nie znajdujesz się w żadnym pojeździe.");
                    return;
                }

                NetHandle    vehicle = API.getPlayerVehicle(player);
                VehicleClass vc      = API.getEntityData(vehicle, "data");

                if (!VehicleClass.IsPlayerHasPermForVehicle(player, vehicle))
                {
                    API.sendNotificationToPlayer(player, "Nie jesteś właścicielem tego pojazdu.");
                    return;
                }

                VehicleClass.ParkVehicle(vehicle);
                API.sendNotificationToPlayer(player, "Pomyślnie zaparkowano pojazd.");
            }
        }
Example #22
0
 public void CreateSelf(VehicleClass _vehicle)
 {
     shipName = _vehicle.ShipName;
     _vehicle.GetPart(out vehicleBase);
     _vehicle.GetPart(out cabin);
     _vehicle.GetPart(out drill);
     _vehicle.GetPart(out engine);
     _vehicle.GetPart(out wheels);
     _vehicle.GetPart(out upgrade);
     crew    = new WorkerBase[4];
     crew[0] = _vehicle.crew[0];
     cost    = _vehicle.cost;
 }
Example #23
0
 public void RefreshInventoryUI(VehicleClass vehicle)
 {
     invCapacityText.text = "Capacity Used: " + vehicle.Inventory.UsedCapacity.ToString("F2") + "/" + vehicle.Inventory.Capacity;
     invFuelText.text     = "Fuel Remaining: " + vehicle.Inventory.GetFuelAmount();
     invRationsText.text  = "Rations Remaining: " + vehicle.Inventory.GetResourceAmount(ResourceId.Rations);
     if (vehicle.MovementScript.IsMining)
     {
         miningModeText.text = "Mining Mode (M): Active";
     }
     else if (!vehicle.MovementScript.IsMining)
     {
         miningModeText.text = "Mining Mode (M): Disabled";
     }
 }
Example #24
0
        /// <summary>
        /// Vehicle constructor with params for all Vehicle attributes
        /// </summary>
        ///
        /// <param name="vehicleRego"> vehicles registration number </param>
        /// <param name="make"> Make of the vehicles </param>
        /// <param name="model"> Model name </param>
        /// <param name="year">Year of the Make</param>
        /// <param name="vehicleClass"> Type of the vehicles </param>
        /// <param name="numSeats"> Total number of seats </param>
        /// <param name="transmissionType"> Automatic vs Manual </param>
        /// <param name="fuelType"> Diesel vs Petrol </param>
        /// <param name="GPS"> Yes or No </param>
        /// <param name="sunRoof">Yes or No </param>
        /// <param name="colour"> Colour of the vehicles </param>
        /// <param name="dailyRate"> Rental cost per day </param>

        public Vehicle(string vehicleRego, string make, string model, int year, VehicleClass vehicleClass, int numSeats,
                       TransmissionType transmissionType, FuelType fuelType, bool GPS, bool sunRoof, string colour, double dailyRate)
        {
            // Setting the class variables to input param. values
            Vehicle_Class     = vehicleClass;
            VehicleRego       = vehicleRego;
            Make              = make;
            Model             = model;
            Year              = year;
            NumSeats          = numSeats;
            Transmission_Type = transmissionType;
            Fuel_Type         = fuelType;
            this.GPS          = GPS;
            SunRoof           = sunRoof;
            DailyRate         = dailyRate;
            Colour            = colour;

            // Setting default values
            if (NumSeats.Equals(0))
            {
                NumSeats = 1;
            }
            if (dailyRate.Equals(0))
            {
                DailyRate = 50;
            }
            if (colour.Equals(""))
            {
                Colour = "Black";
            }
            if (vehicleClass == Vehicle.VehicleClass.Commercial)
            {
                Fuel_Type = Vehicle.FuelType.Diesel;
                DailyRate = 130;
            }
            else if (vehicleClass == Vehicle.VehicleClass.Economy)
            {
                Transmission_Type = Vehicle.TransmissionType.Automatic;
            }
            else if (vehicleClass == Vehicle.VehicleClass.Family)
            {
                DailyRate = 80;
            }
            else
            {
                GPS       = true;
                SunRoof   = true;
                DailyRate = 120;
            }
        } // end Vehicle() constructor
        /// <summary>
        /// </summary>
        static async void PeriodicCheck()
        {
            while (true)
            {
                if (Game.PlayerPed.IsInVehicle())
                {
                    if (!Function.Call <bool>(Hash.DECOR_EXIST_ON, Game.PlayerPed.CurrentVehicle.Handle, "Vehicle.Fuel"))
                    {
                        // For very large random float numbers this method does not yield a uniform distribution
                        // But for this magnitude it is perfectly fine
                        float randomFuel = (float)(minRandomFuel + (maxRandomFuel - minRandomFuel) * (random.NextDouble()));
                        Function.Call(Hash._DECOR_SET_FLOAT, Game.PlayerPed.CurrentVehicle.Handle, "Vehicle.Fuel", randomFuel);
                    }
                    vehicleFuel = Function.Call <float>(Hash._DECOR_GET_FLOAT, Game.PlayerPed.CurrentVehicle.Handle, "Vehicle.Fuel");

                    if (!Function.Call <bool>(Hash.DECOR_EXIST_ON, Game.PlayerPed.CurrentVehicle.Handle, "Vehicle.FuelUsageMultiplier"))
                    {
                        fuelUsageMultiplier = startingMultiplier;
                        //Log.ToChat($"{fuelUsageMultiplier:0.00000}");
                        VehicleClass VehicleClass = (VehicleClass)Function.Call <int>(Hash.GET_VEHICLE_CLASS, Game.PlayerPed.CurrentVehicle.Handle);
                        fuelUsageMultiplier *= (FuelConsumptionClassMultiplier.ContainsKey(VehicleClass) ? FuelConsumptionClassMultiplier[VehicleClass] : 1.0f);
                        fuelUsageMultiplier *= FuelConsumptionModelMultiplier.ContainsKey((VehicleHash)(uint)Game.PlayerPed.CurrentVehicle.Model.Hash) ? FuelConsumptionModelMultiplier[(VehicleHash)(uint)Game.PlayerPed.CurrentVehicle.Model.Hash] : 1f;
                        Function.Call(Hash._DECOR_SET_FLOAT, Game.PlayerPed.CurrentVehicle.Handle, "Vehicle.FuelUsageMultiplier", fuelUsageMultiplier);
                    }
                    if (lastUpdate == -1)
                    {
                        lastUpdate = Function.Call <int>(Hash.GET_GAME_TIMER);
                    }
                    if (fuelUsageMultiplier < 0)
                    {
                        fuelUsageMultiplier = Function.Call <float>(Hash._DECOR_GET_FLOAT, Game.PlayerPed.CurrentVehicle.Handle, "Vehicle.FuelUsageMultiplier");
                    }
                    currentUpdate = Function.Call <int>(Hash.GET_GAME_TIMER);
                    double deltaTime    = (currentUpdate - lastUpdate) / 1000f;
                    float  vehicleSpeed = Math.Abs(Game.PlayerPed.CurrentVehicle.Speed);
                    vehicleFuel = Math.Max(0f, vehicleFuel - (float)(deltaTime * fuelUsageMultiplier * vehicleSpeed));
                    Function.Call(Hash._DECOR_SET_FLOAT, Game.PlayerPed.CurrentVehicle.Handle, "Vehicle.Fuel", vehicleFuel);
                    lastUpdate = currentUpdate;
                }
                else
                {
                    fuelUsageMultiplier = -1;
                    //vehicleFuel = -1;
                    lastUpdate = -1;
                }
                isNearFuelPump = ObjectList.Select(o => new Prop(o)).Where(o => FuelPumpModelHashes.Contains((ObjectHash)(uint)o.Model.Hash)).Any(o => o.Position.DistanceToSquared(Game.PlayerPed.Position) < Math.Pow(2 * FuelPumpRange, 2));
                await BaseScript.Delay(500);
            }
        }
Example #26
0
 public void GoToShipEditor(VehicleClass _vehicle)
 {
     for (int i = 0; i < editorTabs.Count; i++)
     {
         if (editorTabs[i].vehicle == _vehicle)
         {
             selectedShip = _vehicle;
             GoToShipEditor(i);
         }
         else if (editorTabs[i].gameObject.activeSelf)
         {
             editorTabs[i].gameObject.SetActive(false);
         }
     }
 }
Example #27
0
        public static void addVehicleClass(VehicleClass vehicleClass)
        {
            SqlConnection connection = new SqlConnection(ClasesBase.Properties.Settings.Default.conexion);
            SqlCommand    command    = new SqlCommand();

            command.CommandText = "INSERT INTO ClaseVehiculo(cv_descripcion) values(@descripcion)";
            command.CommandType = CommandType.Text;
            command.Connection  = connection;

            command.Parameters.AddWithValue("@descripcion", vehicleClass.Description);

            connection.Open();
            command.ExecuteNonQuery();
            connection.Close();
        }
Example #28
0
 void UpdateWorkers(VehicleClass vehicle)
 {
     for (int cr = 0; cr < vehicle.Crew.Length; cr++)
     {
         if (vehicle.Crew[cr] != null && (equippedWorkerIcons[cr].icon != vehicle.Crew[cr].Portrait || !equippedWorkerIcons[cr].gameObject.activeSelf))
         {
             equippedWorkerIcons[cr].icon.sprite = vehicle.Crew[cr].Portrait;
             equippedWorkerIcons[cr].gameObject.SetActive(true);
         }
         else if (vehicle.Crew[cr] == null && equippedWorkerIcons[cr].gameObject.activeSelf)
         {
             equippedWorkerIcons[cr].gameObject.SetActive(false);
         }
     }
 }
Example #29
0
    void UpdateParts(VehicleClass vehicle)
    {
        vehicle.GetPart(out PartCabin _cabin);
        vehicle.GetPart(out PartDrill _drill);
        vehicle.GetPart(out PartWheel _wheels);
        vehicle.GetPart(out PartEngine _engine);
        vehicle.GetPart(out PartUpgrade _upgrade);

        if (_cabin != null && !installedPartsIcons[1].gameObject.activeSelf)
        {
            installedPartsIcons[1].gameObject.SetActive(true);
            installedPartsIcons[1].icon.sprite = _cabin.Icon;
        }
        else if (_cabin == null && installedPartsIcons[1].gameObject.activeSelf)
        {
            installedPartsIcons[1].gameObject.SetActive(false);
        }

        if (_drill != null && !installedPartsIcons[0].gameObject.activeSelf)
        {
            installedPartsIcons[0].gameObject.SetActive(true);
            installedPartsIcons[0].icon.sprite = _drill.Icon;
        }
        else if (_drill == null && installedPartsIcons[0].gameObject.activeSelf)
        {
            installedPartsIcons[0].gameObject.SetActive(false);
        }

        if (_engine != null && !installedPartsIcons[2].gameObject.activeSelf)
        {
            installedPartsIcons[2].gameObject.SetActive(true);
            installedPartsIcons[2].icon.sprite = _engine.Icon;
        }
        else if (_engine == null && installedPartsIcons[2].gameObject.activeSelf)
        {
            installedPartsIcons[2].gameObject.SetActive(false);
        }

        if (_wheels != null && !installedPartsIcons[3].gameObject.activeSelf)
        {
            installedPartsIcons[3].gameObject.SetActive(true);
            installedPartsIcons[3].icon.sprite = _wheels.Icon;
        }
        else if (_wheels == null && installedPartsIcons[3].gameObject.activeSelf)
        {
            installedPartsIcons[3].gameObject.SetActive(false);
        }
    }
 public static VehicleHash GetRandomVehicleByClass(VehicleClass vClass)
 {
     // ISSUE: object of a compiler-generated type is created
     // ISSUE: variable of a compiler-generated type
     Database.\u003C\u003Ec__DisplayClass29_0 cDisplayClass290 = new Database.\u003C\u003Ec__DisplayClass29_0();
     // ISSUE: reference to a compiler-generated field
     cDisplayClass290.vClass = vClass;
     VehicleHash[] values = Enum.GetValues(typeof(VehicleHash)) as VehicleHash[];
     if (values == null)
     {
         return((VehicleHash) - 1216765807);
     }
     // ISSUE: method pointer
     VehicleHash[] array = ((IEnumerable <VehicleHash>)Enumerable.Where <VehicleHash>((IEnumerable <M0>)values, (Func <M0, bool>) new Func <VehicleHash, bool>((object)cDisplayClass290, __methodptr(\u003CGetRandomVehicleByClass\u003Eb__0)))).ToArray <VehicleHash>();
     return((VehicleHash)(int)(uint)array[Database.Random.Next(array.Length)]);
 }
Example #31
0
 public VehicleInfo(int _tier, int _speed, VehicleClass _vClass)
 {
     this.tier = _tier;
     this.speed = _speed;
     this.vClass = _vClass;
 }
Example #32
0
        private string GetMasterData()
        {
            DBModels.BeeServiceEntities2 context = new DBModels.BeeServiceEntities2();
            var vehicleTypes = context.VehicleTypes.Where((e) =>e.Status==0);

            List<MasterData> lstvehMasterData = new List<MasterData>();

            foreach (var vehicleType in vehicleTypes)
            {

                MasterData vehMasterData = new MasterData();

                vehMasterData.Type = vehicleType.TYPE;
                vehMasterData.ID = vehicleType.ID;

                //Adding vehicle classes

                var vehicleClasses = context.VehicleClasses.Where((e) => e.VehichleTypeID == vehicleType.ID && e.Status == 0);

                var classes = new List<VehicleClass>();

                foreach (var vehicleClass in vehicleClasses)
                {
                    var vClass = new VehicleClass() { ID = vehicleClass.ID, Name = vehicleClass.Class };

                    //Adding service types to master data
                    var serviceTypes = context.ServiceTypes.Where((e) => e.VehicleClassID == vehicleClass.ID && e.Status == 0);

                    var Types = new List<ServiceType>();

                    foreach (var serviceType in serviceTypes)
                    {
                        var sType = new ServiceType() { ID = serviceType.ID, Name = serviceType.ServiceType1, Duration = serviceType.Duration.Value, Cost = serviceType.Cost.Value };
                        //Adding vehicle Addons

                        var serviceAddOns = context.AddOns.Where((e) => e.ServiceTypeID == sType.ID && e.Status == 0);

                        var addOns = new List<ServiceAddon>();

                        foreach (var serviceAddOn in serviceAddOns)
                        {
                            addOns.Add(new ServiceAddon() { ID = serviceAddOn.ID, Name = serviceAddOn.AddOn1, Cost = serviceAddOn.Cost.Value, Duration = serviceAddOn.Duration.Value });
                        }

                        sType.Addons = addOns;

                        Types.Add(sType);
                    }

                    vClass.Services = Types;

                    classes.Add(vClass);
                }

                vehMasterData.Classes = classes;

                lstvehMasterData.Add(vehMasterData);

            }

            JsonSerializerSettings settings = new JsonSerializerSettings()
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            string strMasterData = JsonConvert.SerializeObject(lstvehMasterData, settings);

            return strMasterData;
        }
Example #33
0
 public VehicleInfo()
 {
     this.tier = 0;
     this.speed = 0;
     this.vClass = VehicleClass.ERROR;
 }