Beispiel #1
0
        private void btnTrucker_Click(object sender, EventArgs e)
        {
            Trucker trucker    = new Trucker();
            bool    isFormOpen = IsAlreadyOpen(typeof(Trucker));

            if (isFormOpen == false)
            {
                trucker.Show();
            }
        }
Beispiel #2
0
        public async Task <List <Job> > SetDistance(List <Job> jobs, Trucker foundUser, string direction)
        {
            foreach (var job in jobs)
            {
                var result = await _distance.GetDistance(job, foundUser, direction);

                job.Distance = ConvertToDouble(result);
            }
            return(jobs);
        }
Beispiel #3
0
        public async Task <IActionResult> AddTrucker(Trucker t)
        {
            if (ModelState.IsValid)
            {
                t.Manager = await _userManager.GetUserAsync(User);

                _db.Trucker.Add(t);
                _db.SaveChanges();
            }
            return(await Task.Run(() => RedirectToAction("Index")));
        }
Beispiel #4
0
        private void TickEvent(List <Events.TickNametagData> nametags)
        {
            // Check if the player is connected
            if (!playerLogged)
            {
                return;
            }

            DateTime dateTime = DateTime.UtcNow;

            if (Vehicles.lastPosition != null)
            {
                // Update the speedometer
                Vehicles.UpdateSpeedometer();
            }

            // Update the player's money each 450ms
            if (dateTime.Ticks - lastTimeChecked.Ticks >= 4500000)
            {
                // Check if the player is loaded
                object money = Player.LocalPlayer.GetSharedData("PLAYER_MONEY");

                if (money != null)
                {
                    playerMoney     = Convert.ToInt32(money) + "$";
                    lastTimeChecked = dateTime;
                }
            }

            if (Fishing.fishingState > 0)
            {
                // Start the fishing minigame
                Fishing.DrawFishingMinigame();
            }

            // Draw the money
            RAGE.NUI.UIResText.Draw(playerMoney, 1900, 60, RAGE.Game.Font.Pricedown, 0.5f, Color.DarkOliveGreen, RAGE.NUI.UIResText.Alignment.Right, true, true, 0);

            // Check if the player
            if (RAGE.Game.Pad.IsControlJustPressed(0, (int)RAGE.Game.Control.VehicleSubPitchDownOnly) && Player.LocalPlayer.Vehicle != null)
            {
                // Check if the player is on a forklift
                Trucker.CheckPlayerStoredCrate();
            }

            // Detect if a key has been pressed
            int key = Keys.DetectPressedKey(dateTime.Ticks);

            if (key >= 0)
            {
                // Fire the event for the pressed key
                Keys.FireKeyPressed(key);
            }
        }
        public async Task <CoordsJson> GetCoords(Trucker trucker)
        {
            HttpClient          client   = new HttpClient();
            HttpResponseMessage response = await client.GetAsync($"https://maps.googleapis.com/maps/api/geocode/json?address={trucker.HomeAddress},US&sensor=false&key={ApiKeys.GoogleKey}");

            if (response.IsSuccessStatusCode)
            {
                string json = response.Content.ReadAsStringAsync().Result;
                return(JsonConvert.DeserializeObject <CoordsJson>(json));
            }
            return(null);
        }
 public ViewTruckerViewModel(Trucker trucker,
                             IQueryable <TruckerLog> truckerLogs,
                             List <Segment> travelSegments,
                             Manager manager,
                             long daysDisplay,
                             long upperTime)
 {
     Trucker     = trucker;
     TruckerLogs = truckerLogs;
     Segments    = travelSegments;
     Manager     = manager;
     DaysDisplay = daysDisplay;
     UpperTime   = upperTime;
 }
Beispiel #7
0
 public ActionResult Edit(int id, Trucker trucker)
 {
     try
     {
         // TODO: Add update logic here
         var userId    = User.FindFirstValue(ClaimTypes.NameIdentifier);
         var foundUser = _repo.Trucker.FindByCondition(a => a.IdentityUserId == userId).SingleOrDefault();
         foundUser.CompanyName = trucker.CompanyName;
         foundUser.FirstName   = trucker.FirstName;
         foundUser.HomeAddress = trucker.HomeAddress;
         foundUser.LastName    = trucker.LastName;
         _repo.Trucker.Update(foundUser);
         _repo.Save();
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #8
0
        public ActionResult Create(Trucker trucker)
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            try
            {
                // TODO: Add insert logic here
                var coords = _geocode.GetCoords(trucker);
                trucker.Latitude       = coords.Result.results[0].geometry.location.lat;
                trucker.Longitude      = coords.Result.results[0].geometry.location.lng;
                trucker.IdentityUserId = userId;
                _repo.Trucker.Create(trucker);
                _repo.Save();
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #9
0
        public async Task <DistanceJson> GetDistance(Job job, Trucker trucker, string endPoints)
        {
            string url = "";

            if (endPoints == "HomeToSite")
            {
                url = $"https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins={trucker.HomeAddress}&destinations={job.Site.Latitude},{job.Site.Longitude}&key={ApiKeys.GoogleKey}";
            }
            else if (endPoints == "MillToNextSite")
            {
                url = $"https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins={job.Site.Latitude},{job.Site.Longitude}&destinations={job.Mill.Address}&key={ApiKeys.GoogleKey}";
            }
            HttpClient          client   = new HttpClient();
            HttpResponseMessage response = await client.GetAsync(url);

            if (response.IsSuccessStatusCode)
            {
                string json = response.Content.ReadAsStringAsync().Result;
                return(JsonConvert.DeserializeObject <DistanceJson>(json));
            }
            return(null);
        }
Beispiel #10
0
    void Awake()
    {
        text.text = "Press A to turn LEFT and D to turn RIGHT\nOutput displayed in the debug console";

        //Human plus gas
        IFuel   gas         = new Gas();
        IDriver humanDriver = new Human();

        m_PlayerCar.SetFuel(gas);
        m_PlayerCar.SetDriver(humanDriver);
        m_PlayerCar.FuelCar();

        //AI plus electric
        IFuel   electric = new Electric();
        IDriver artificialIntelligence = new AI();

        m_AICar.SetFuel(electric);
        m_AICar.SetDriver(artificialIntelligence);
        m_AICar.FuelCar();

        //Millionaire plus rainbow
        IFuel   rainbow     = new Rainbow();
        IDriver millionaire = new Millionaire();

        m_FakeCar.SetFuel(rainbow);
        m_FakeCar.SetDriver(millionaire);
        m_FakeCar.FuelCar();

        //Trucker plus diesel
        IFuel   diesel  = new Diesel();
        IDriver trucker = new Trucker();

        m_TruckerTruck.SetFuel(diesel);
        m_TruckerTruck.SetDriver(trucker);
        m_TruckerTruck.FuelCar();
    }
        /// <summary>
        /// OnCalloutAccepted is where we begin our callout's logic. In this instance we create our pursuit and add our ped from eariler to the pursuit as well
        /// </summary>
        /// <returns></returns>
        public override bool OnCalloutAccepted()
        {
            //We accepted the callout, so lets initilize our blip from before and attach it to our ped so we know where he is.
            rockBlip       = new Blip(spawnPoint);
            rockBlip.Color = Color.Yellow;
            rockBlip.EnableRoute(Color.Yellow);

            GameFiber.StartNew(delegate
            {
                state = ERocksBlockingRoadState.EnRoute;

                while (true)
                {
                    if (breakForceEnd)
                    {
                        break;
                    }

                    switch (state)
                    {
                    case ERocksBlockingRoadState.EnRoute:
                        //Game.DisplayNotification("State: EnRoute");
                        while (true)
                        {
                            GameFiber.Yield();
                            if (Vector3.Distance(Game.LocalPlayer.Character.Position, spawnPoint) < 30.0f)
                            {
                                state = ERocksBlockingRoadState.OnScene;
                                break;
                            }
                            if (breakForceEnd)
                            {
                                break;
                            }
                        }
                        break;


                    case ERocksBlockingRoadState.OnScene:
                        //Game.DisplayNotification("State: OnScene");
                        while (true)
                        {
                            GameFiber.Yield();
                            Game.DisplayHelp("Press ~b~" + Controls.PrimaryAction.ToUserFriendlyName() + "~w~ to call a truck");
                            if (Controls.PrimaryAction.IsJustPressed())
                            {
                                state = ERocksBlockingRoadState.CallTruck;
                                break;
                            }
                            if (breakForceEnd)
                            {
                                break;
                            }
                        }
                        break;


                    case ERocksBlockingRoadState.CallTruck:
                        //Game.DisplayNotification("State: CallTruck");
                        Vector3 spawnPos = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.AroundPosition(150f));
                        while (spawnPos.DistanceTo(Game.LocalPlayer.Character.Position) < 50.0f)
                        {
                            spawnPos = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.AroundPosition(150.0f));
                            GameFiber.Yield();
                        }
                        Trucker trucker    = new Trucker("s_m_m_trucker_01", spawnPos, 0.0f);
                        Vector3 posToDrive = spawnPoint.AroundPosition(12.5f);
                        Vector3 posToWalk  = spawnPoint.AroundPosition(3.0f);
                        trucker.Job(posToDrive, posToWalk);

                        while (true)
                        {
                            if (breakForceEnd)
                            {
                                break;
                            }

                            if (Vector3.Distance(posToWalk, trucker.Position) < 4.0f && trucker.Speed <= 0.5f)
                            {
                                GameFiber.Wait(4500);

                                foreach (Rage.Object rockObj in rocksList)
                                {
                                    if (rockObj.Exists() && !breakForceEnd)
                                    {
                                        rockObj.Delete();
                                    }
                                }

                                break;
                            }
                            GameFiber.Yield();
                        }

                        this.End();
                        break;


                    default:
                        break;
                    }

                    GameFiber.Yield();
                }
            });

            return(base.OnCalloutAccepted());
        }
 public static Trucker ToEntity(this TruckerModel model, Trucker destination)
 {
     return(AutoMapperConfiguration.Mapper.Map(model, destination));
 }
 public static TruckerModel ToModel(this Trucker entity)
 {
     return(AutoMapperConfiguration.Mapper.Map <Trucker, TruckerModel>(entity));
 }
Beispiel #14
0
 public IQueryable <JobBid> ReturnWinningBids(Trucker trucker) => FindByCondition(a => a.TruckerId == trucker.TruckerId && a.IsWinningBid == true);
Beispiel #15
0
        // GET: /Fleet/SetRules/
        public async Task <IActionResult> SetRules(Trucker t)
        {
            var manager = await _userManager.GetUserAsync(User);

            return(View(manager));
        }
Beispiel #16
0
        private void TickEvent(List <Events.TickNametagData> nametags)
        {
            // Get the current time
            DateTime dateTime = DateTime.UtcNow;

            // Check if the player is connected
            if (playerLogged)
            {
                // Disable hitting with the weapon
                RAGE.Game.Pad.DisableControlAction(0, 140, true);
                RAGE.Game.Pad.DisableControlAction(0, 141, true);

                if (Vehicles.lastPosition != null)
                {
                    if (Player.LocalPlayer.Vehicle == null)
                    {
                        // He fell from the vehicle, save the data
                        Vehicles.RemoveSpeedometerEvent(null);
                    }
                    else
                    {
                        // Update the speedometer
                        Vehicles.UpdateSpeedometer();
                    }
                }

                // Update the player's money each 450ms
                if (dateTime.Ticks - lastTimeChecked.Ticks >= 4500000)
                {
                    // Check if the player is loaded
                    object money = Player.LocalPlayer.GetSharedData(Constants.HAND_MONEY);

                    if (money != null)
                    {
                        playerMoney     = Convert.ToInt32(money) + "$";
                        lastTimeChecked = dateTime;
                    }
                }

                if (Fishing.fishingState > 0)
                {
                    // Start the fishing minigame
                    Fishing.DrawFishingMinigame();
                }

                // Draw the money
                RAGE.NUI.UIResText.Draw(playerMoney, 1900, 60, RAGE.Game.Font.Pricedown, 0.5f, Color.DarkOliveGreen, RAGE.NUI.UIResText.Alignment.Right, true, true, 0);

                // Check if the player
                if (RAGE.Game.Pad.IsControlJustPressed(0, (int)RAGE.Game.Control.VehicleSubPitchDownOnly) && Player.LocalPlayer.Vehicle != null)
                {
                    // Check if the player is on a forklift
                    Trucker.CheckPlayerStoredCrate();
                }

                // Check if the player is handcuffed
                if (Police.handcuffed)
                {
                    RAGE.Game.Pad.DisableControlAction(0, 12, true);
                    RAGE.Game.Pad.DisableControlAction(0, 13, true);
                    RAGE.Game.Pad.DisableControlAction(0, 14, true);
                    RAGE.Game.Pad.DisableControlAction(0, 15, true);
                    RAGE.Game.Pad.DisableControlAction(0, 16, true);
                    RAGE.Game.Pad.DisableControlAction(0, 17, true);
                    RAGE.Game.Pad.DisableControlAction(0, 22, true);
                    RAGE.Game.Pad.DisableControlAction(0, 24, true);
                    RAGE.Game.Pad.DisableControlAction(0, 25, true);
                }
            }

            // Detect if a key has been pressed
            int key = Keys.DetectPressedKey(dateTime.Ticks);

            if (key >= 0)
            {
                // Fire the event for the pressed key
                Keys.FireKeyPressed(key);
            }
        }
Beispiel #17
0
        private void TickEvent(List <Events.TickNametagData> nametags)
        {
            // Get the current time
            var dateTime = DateTime.UtcNow;

            // Check if the player is connected
            if (playerLogged)
            {
                // Disable reloading
                Pad.DisableControlAction(0, 140, true);

                if (Vehicles.lastPosition != null)
                {
                    if (Player.LocalPlayer.Vehicle == null)
                    {
                        Vehicles.RemoveSpeedometerEvent(null);
                    }
                    else
                    {
                        Vehicles.UpdateSpeedometer();
                    }
                }

                // Update the player's money each 450ms
                if (dateTime.Ticks - lastTimeChecked.Ticks >= 4500000)
                {
                    // Check if the player is loaded
                    var money = Player.LocalPlayer.GetSharedData(Constants.HAND_MONEY);

                    if (money != null)
                    {
                        playerMoney     = Convert.ToInt32(money) + "$";
                        lastTimeChecked = dateTime;
                    }
                }

                if (Fishing.fishingState > 0)
                {
                    Fishing.DrawFishingMinigame();
                }

                // Draw the money
                UIResText.Draw(playerMoney, 1900, 60, Font.Pricedown, 0.5f, Color.DarkOliveGreen,
                               UIResText.Alignment.Right, true, true, 0);

                // Check if the player
                if (Pad.IsControlJustPressed(0, (int)Control.VehicleSubPitchDownOnly) &&
                    Player.LocalPlayer.Vehicle != null)
                {
                    Trucker.CheckPlayerStoredCrate();
                }

                // Check if the player is handcuffed
                if (Police.handcuffed)
                {
                    Pad.DisableControlAction(0, 12, true);
                    Pad.DisableControlAction(0, 13, true);
                    Pad.DisableControlAction(0, 14, true);
                    Pad.DisableControlAction(0, 15, true);
                    Pad.DisableControlAction(0, 16, true);
                    Pad.DisableControlAction(0, 17, true);
                    Pad.DisableControlAction(0, 22, true);
                    Pad.DisableControlAction(0, 24, true);
                    Pad.DisableControlAction(0, 25, true);
                }
            }

            // Detect if a key has been pressed
            var key = Keys.DetectPressedKey(dateTime.Ticks);

            if (key >= 0)
            {
                Keys.FireKeyPressed(key);
            }
        }