Пример #1
0
        public CarStatus DeleteCar(Car car)
        {
            CarStatus carStatus = new CarStatus();

            if (_context.Cars.Count(c => c.RegistrationNumber.Equals(car.RegistrationNumber)) > 0)
            {
                try
                {
                    _context.Cars.Remove(car);
                    _context.SaveChanges();
                    carStatus.Status  = "Ok";
                    carStatus.Message = "Pomyślnie usunięto";
                    return(carStatus);
                }
                catch
                {
                    carStatus.Status  = "Failed";
                    carStatus.Message = "nie udało się usunąć samochodu";
                    return(carStatus);
                }
            }
            else
            {
                carStatus.Status  = "Failed";
                carStatus.Message = "nie ma takiego samochodu";
                return(carStatus);
            }
        }
Пример #2
0
        public CarStatus AddFault(int carId, Fault fault)
        {
            CarStatus carStatus = new CarStatus();

            if (_context.Faults.Count(c => c.CarId.Equals(carId)) > 0 && _context.Faults.Count(c => c.FaultId.Equals(fault.FaultId)) > 0)
            {
                _context.Faults.Update(fault);
                _context.SaveChanges();
                carStatus.Message = "Naprawa zaktualizowana pomyślnie";
                carStatus.Status  = "ok";
            }
            else if (_context.Cars.Count(c => c.Id.Equals(carId)) > 0)
            {
                _context.Faults.Add(fault);
                _context.SaveChanges();
                carStatus.Message = "Naprawa dodana pomyślnie";
                carStatus.Status  = "ok";
            }
            else
            {
                carStatus.Message = "Nie udało się dodać naprawy";
                carStatus.Status  = "Failed";
            }
            return(carStatus);
        }
        /// <summary>
        /// Generates the Car Status Payload based on the CarDetails and Payload required
        /// </summary>
        /// <param name="carDetails"></param>
        /// <param name="statusPayloadType"></param>
        /// <returns></returns>
        public static CarStatus GenerateCarStatusPayload(this CarDetails carDetails, StatusPayloadType statusPayloadType)
        {
            CarStatus result = new CarStatus
            {
                CarIndex  = carDetails.CarIndex,
                TimeStamp = carDetails.CarLocationData.TimeStamp,
                Type      = statusPayloadType.ToString().ToUpperInvariant()
            };

            switch (statusPayloadType)
            {
            case StatusPayloadType.Position:
                result.Value = carDetails.Rank;
                break;

            case StatusPayloadType.Speed:
                result.Value = (int)carDetails.CurrentSpeed;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(statusPayloadType), statusPayloadType, $"The payload type {statusPayloadType} isn't yet support");
            }

            return(result);
        }
Пример #4
0
        public void CarEmergencyCase()
        {
            Random rnd = new Random();

            BumpInto += () => CrashStatus = (CarStatus)rnd.Next(0, 2);
            EmergencyCase();
        }
Пример #5
0
            private bool CurrentCarWillCollideLater(CarStatus current, Stack <CarStatus> stack)
            {
                CarStatus next = stack.Peek();

                current.WhenCollide = current.Speed <= next.Speed ? -1 : (next.Position - current.Position) * 1.0 / (current.Speed - next.Speed);
                return(current.WhenCollide < 0 || (current.WhenCollide > next.WhenCollide && next.WhenCollide > 0));
            }
Пример #6
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Wall" && bouncing < maxBouncing)
        {
            ContactPoint cp = collision.contacts[0];
            //rigidbody.velocity = Vector3.Reflect(rigidbody.velocity,collision.collider.transform.position.normalized);
            rigidbody.velocity = Vector3.Reflect(rigidbody.velocity, cp.normal) * 2;
            bouncing++;
        }
        else
        {
            if (collision.gameObject.GetComponent <CarStatus>() != null)
            {
                CarStatus car = collision.gameObject.GetComponent <CarStatus>();
                car.infligerDegat(damage);
            }

            GameObject            prefabExplosion = Resources.Load("Explosion") as GameObject;
            ExplosionPhysicsForce epf             = prefabExplosion.GetComponent <ExplosionPhysicsForce>();
            epf.explosionForce = 1;
            prefabExplosion.transform.position = this.transform.position;
            GameObject explosion = Instantiate(prefabExplosion) as GameObject;

            GameObject.Destroy(this.gameObject);
            GameObject.Destroy(explosion, 3);
        }
    }
Пример #7
0
        public void UpdateStatus(int carId, CarStatus status)
        {
            var model = Get(carId);

            model.Status = status;
            DB.SaveChanges();
        }
Пример #8
0
 public void Run(Node node)
 {
     if (Status == CarStatus.Idle)
     {
         var n = Simulation.Graph.FindingTheNearestPoint(Position);
         Position = n.Coordinate;
         var path = Simulation.Graph.NewPath(n, node);
         if (path != null)
         {
             currentPath              = path;
             currentPath.OnEndedPath += CurrentPath_OnEndedPath;
             Status = CarStatus.Run;
         }
         else
         {
             if (n == node)
             {
                 InteractObject(node);
             }
         }
     }
     else
     {
         Tools.Message(MessageStatus.Warning, string.Format(Localization.GetText("Text59"), Id), true);
     }
 }
Пример #9
0
        public CarStatusViewModel(CarStatus carStatus)
        {
            ID              = carStatus.ID;
            BeginDate       = carStatus.BeginDate;
            EndDate         = carStatus.EndDate;
            CarId           = carStatus.CarId;
            Car             = carStatus.Car;
            StatusId        = carStatus.StatusId;
            Status          = carStatus.Status;
            LocationId      = carStatus.LocationId;
            Location        = carStatus.Location;
            UnitId          = carStatus.UnitId;
            Unit            = carStatus.Unit;
            Comment         = carStatus.Comment;
            IsEnableService = carStatus.IsEnableService;

            if (!carStatus.Car.CarOwner.IsFirm)
            {
                IsPrivat = true;
            }
            if (Car.CarOwnerId != Unit.Firm.EmployeeId)
            {
                IsRentCar = true;
            }
        }
Пример #10
0
    public override void activateSkill()
    {
        CarStatus  attacker      = GetComponent <CarStatus>();
        float      itemPutOffset = 5;
        Vector3    spawnPosition = transform.position + 2 * transform.forward * itemPutOffset;
        Quaternion spawnRotation = Quaternion.Euler(new Vector3(0, transform.rotation.eulerAngles.y, 0));
        GameObject weapon        = Instantiate(coinBullet, spawnPosition, spawnRotation, transform);

        weapon.GetComponent <TrapWeapons>().attacker = attacker;


        spawnPosition = transform.position + 2 * transform.forward * itemPutOffset;
        spawnRotation = Quaternion.Euler(new Vector3(0, transform.rotation.eulerAngles.y + 30, 0));
        weapon        = Instantiate(coinBullet, spawnPosition, spawnRotation, transform);
        weapon.GetComponent <TrapWeapons>().attacker = attacker;


        spawnPosition = transform.position + 2 * transform.forward * itemPutOffset;
        spawnRotation = Quaternion.Euler(new Vector3(0, transform.rotation.eulerAngles.y - 30, 0));
        weapon        = Instantiate(coinBullet, spawnPosition, spawnRotation, transform);
        weapon.GetComponent <TrapWeapons>().attacker = attacker;

        if (skillAudio == null)
        {
            return;
        }
        // play once
        AudioSource source = gameObject.AddComponent <AudioSource>();

        source.clip   = skillAudio;
        source.volume = 1;
        source.loop   = false;
        source.Play();
    }
Пример #11
0
    GameObject getBestCar()
    {
        GameObject bestCar = null;

        foreach (var car in carSpawner.cars)
        {
            CarStatus carStatus = car.GetComponent <CarStatus>();

            if (bestCar == null)
            {
                bestCar = car;
            }
            else
            {
                CarStatus bestCarStatus = bestCar.GetComponent <CarStatus>();
                if (carStatus.carGasStationCatchs > bestCarStatus.carGasStationCatchs)
                {
                    bestCar = car;
                }
                else if (carStatus.carGasStationCatchs == bestCarStatus.carGasStationCatchs)
                {
                    if (carStatus.distanceToNextGasStation < bestCarStatus.distanceToNextGasStation)
                    {
                        bestCar = car;
                    }
                }
            }
        }
        return(bestCar);
    }
Пример #12
0
    private void RespondToTrafficLight(TrafficLightController.TrafficLightState theState)
    {
        // Decide on what to depending on the status
        switch (theState)
        {
        case TrafficLightController.TrafficLightState.Green:
            m_carStatus      = CarStatus.Accelerating;
            m_TargetSpeed    = MaxSpeed;
            AccelerationRate = DefaultAccelerationRate;
            // Debug.Log("The traffic light is Green");
            break;

        case TrafficLightController.TrafficLightState.Red:
            m_carStatus   = CarStatus.SlowingDown;
            m_TargetSpeed = 0;
            BrakeRate     = FastBrakeRate;
            //  Debug.Log("The traffic light is Red");
            break;

        case TrafficLightController.TrafficLightState.Amber:
            m_carStatus   = CarStatus.SlowingDown;
            BrakeRate     = DefaultBrakeRate;
            m_TargetSpeed = MaxSpeed * .2f;
            // Debug.Log("The traffic light is Amber");
            break;

        default:
            break;
        }
    }
Пример #13
0
    public void decreaseHP(float point, CarStatus attacker = null)
    {
        float decreasedAmount = Mathf.Min(point * Mathf.Max(0, 1 - damageReduction), currHP);

        // it is possible being attack by yourself if your poison ability is reflected
        if (attacker != null && attacker != this && attacker.lifeStealAbility > 0)
        {
            float lsAmount = decreasedAmount * attacker.lifeStealAbility;
            if (lsAmount > 0)
            {
                attacker.increaseHP(lsAmount);
            }
        }
        currHP = Mathf.Clamp(currHP - decreasedAmount, 0, currHP);
        // destroy  car
        if (currHP <= 0)
        {
            if (reviveAbility > 0)
            {
                --reviveAbility;
                currHP       = getMaxHP();
                currMP       = getMaxMP();
                poisonTimer  = poisonTime + 1;
                stunnedTimer = stunningTime + 1;
                Quaternion spwanRot = Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(90, 0, 0));
                Instantiate(reviveAnime, transform.position, spwanRot, transform);
            }
            else
            {
                Instantiate(explosionOnDead, transform.position, transform.rotation);
                Destroy(gameObject);
            }
        }
    }
Пример #14
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,BeginDate,EndDate,CarId,StatusId,UnitId,Comment")] CarStatus carStatus)
        {
            if (id != carStatus.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(carStatus);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CarStatusExists(carStatus.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CarId"]    = new SelectList(_context.Cars, "Id", "Id", carStatus.CarId);
            ViewData["StatusId"] = new SelectList(_context.Statuses, "StatusID", "StatusID", carStatus.StatusId);
            ViewData["UnitId"]   = new SelectList(_context.Units, "UnitId", "UnitId", carStatus.UnitId);
            return(View(carStatus));
        }
Пример #15
0
 private void ResponseToVehicle(Collider other)
 {
     // Check how close we are to decie how much we need to break
     m_carStatus   = CarStatus.SlowingDown;
     m_TargetSpeed = other.transform.GetComponent <CarController>().Speed;
     BrakeRate     = FastBrakeRate;
 }
Пример #16
0
        public virtual void Stop()
        {
            currentStatus = CarStatus.Stopped;
            currentspeed  = 0;

            HandlersInvoke(StopEvent, $"Машинка {Model} - {Factory} - {MaxSpeed} остановилась");
        }
Пример #17
0
        public void ChangeStatus(int ID, CarStatus Status)
        {
            var entity = this._DB.Get(ID);

            entity.Status = (int)Status;
            this._DB.Edit(entity);
        }
Пример #18
0
    // Use this for initialization
    void Start()
    {
        r = new System.Random();

        generateLocations();

        float rand = r.Next(0, 4);

        if (rand < 1)
        {
            currentObjective = new Location(this, r);
        }
        else if (rand < 2)
        {
            currentObjective = new Hit(this, r);
        }
        else if (rand < 3)
        {
            CarStatus cs = (CarStatus)PLAYER.GetComponent("CarStatus");
            currentObjective = new Taxi(this, r, cs, DUDE);
        }
        else if (rand < 4)
        {
            currentObjective = new Bank(this);
        }
        displayObjective(currentObjective.getDescription());
    }
Пример #19
0
 public bool EditCar(CarStatus changedCar)
 {
     try
     {
         using (CarRentEntities db = new CarRentEntities())
         {
             cars_tbl car = db.cars_tbl.FirstOrDefault(c => c.PlateNumber == changedCar.PlateNumber);
             if (car != null)
             {
                 car.ActuallyKm      = changedCar.ActuallyKm;
                 car.AvaibleToBeRent = changedCar.AvaibleToBeRent;
                 car.ProperToBeRent  = changedCar.ProperToBeRent;
                 car.Picture         = changedCar.Picture;
                 car.DayPrice        = changedCar.DayPrice;
                 car.DayDelayPrice   = changedCar.DayDelayPrice;
                 car.PlateNumber     = changedCar.PlateNumber;
                 db.SaveChanges();
                 return(true);
             }
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #20
0
        /// <summary>
        /// Sets a new car status of the driverID's car
        /// </summary>
        /// <param name="driverId"></param>
        /// <param name="carStatus"></param>
        public void ChangeCarStatus(string driverId, CarStatus carStatus)
        {
            var driver = _data.Drivers.Where(x => x.UserId == driverId).Include(x => x.Car).FirstOrDefault();

            driver.Car.CarStatus = carStatus;
            _data.SaveChanges();
        }
Пример #21
0
        }                                                          // дата завершения ремонта

        public Car(string model, string regNumber, CarStatus status, DateTime repairAcceptanceDate, DateTime repairCompletionDate = default)
        {
            Model                = model;
            RegNumber            = regNumber;
            Status               = status;
            RepairAcceptanceDate = repairAcceptanceDate;
            RepairCompletionDate = RepairAcceptanceDate.AddDays(Init.rand.Next(0, 7));
        }
Пример #22
0
        public void Generate_Speed_CarStatus_Payload()
        {
            CarDetails carDetails = JsonConvert.DeserializeObject <CarDetails>(FirstCarAddedPayload);

            CarStatus actualResult = carDetails.GenerateCarStatusPayload(StatusPayloadType.Speed);

            Assert.AreEqual(ExpectedSpeedCarStatus, actualResult.ToString());
        }
Пример #23
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject.tag == "Player")
     {
         CarStatus cs = (CarStatus)coll.gameObject.GetComponent("CarStatus");
         cs.FUEL = 100;
         GAMELOGIC.addToQueue("Fuel refilled!");
     }
 }
Пример #24
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == "Player")
     {
         CarStatus cs = (CarStatus)coll.gameObject.GetComponent("CarStatus");
         cs.takeDamage();
         AudioHelper.Instance.MakeCrashSound();
     }
 }
Пример #25
0
    // Use this for initialization
    private void Start()
    {
        m_RB          = GetComponent <Rigidbody>();
        m_carStatus   = CarStatus.Accelerating;
        m_TargetSpeed = MaxSpeed;

        AccelerationRate = DefaultAccelerationRate;
        BrakeRate        = DefaultBrakeRate;
    }
Пример #26
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject.tag == "Player")
     {
         CarStatus cs = (CarStatus)coll.gameObject.GetComponent("CarStatus");
         cs.HEALTH = 100;
         GAMELOGIC.addToQueue("Car repaired!");
     }
 }
Пример #27
0
    // Update is called once per frame
    void Update()
    {
        if (gameOver)
        {
            foreach (GameObject g in doges)
            {
                g.transform.Rotate(new Vector3(0, 0, 1));
            }
            return;
        }

        timer = Mathf.Max(timer - Time.deltaTime, 0);
        if (timer == 0)
        {
            GameOver("You ran out of time to complete the objective.");
        }

        int    minutes = (Mathf.FloorToInt(timer)) / 60;
        int    seconds = (Mathf.FloorToInt(timer)) % 60;
        string minZero = "", minMin = "";

        if (minutes < 10)
        {
            minMin = "0";
        }
        if (seconds < 10)
        {
            minZero = "0";
        }
        TIME.text = "Time remaining: " + minMin + minutes + ":" + minZero + seconds;

        if (currentObjective == null)
        {
            float rand = r.Next(3);
            if (rand < 1)
            {
                currentObjective = new Location(this, r);
            }
            else if (rand < 2)
            {
                currentObjective = new Hit(this, r);
            }
            else if (rand < 3)
            {
                CarStatus cs = (CarStatus)PLAYER.GetComponent("CarStatus");
                currentObjective = new Taxi(this, r, cs, DUDE);
            }
            timer += timeBonus;
            addToQueue("Plus " + timeBonus + "s bonus time!");
            displayObjective(currentObjective.getDescription());
        }
        else
        {
            currentObjective.Update();
        }
    }
Пример #28
0
 private void UpdateStatusAfterBroken()
 {
     if (Status == CarStatus.Broken)
     {
         if ((Fuel > 0) && (wearout < Settings.LimitWearout))
         {
             Status = CarStatus.Idle;
         }
     }
 }
Пример #29
0
 public Car(string model)
 {
     Model        = model;
     Id           = new Guid();
     Status       = CarStatus.Free;
     RentCount    = 0;
     ServiceCount = 0;
     RentStart    = DateTimeOffset.Now;
     RentDuration = TimeSpan.Zero;
 }
Пример #30
0
 public Car(string model, Guid id, CarStatus status, int rentCount, int serviceCount, DateTimeOffset rentStart, TimeSpan rentDuration)
 {
     Model        = model;
     Id           = id;
     Status       = status;
     RentCount    = rentCount;
     ServiceCount = serviceCount;
     RentStart    = rentStart;
     RentDuration = rentDuration;
 }
Пример #31
0
 public abstract void Execute(CarStatus car);
Пример #32
0
 public override void Execute(CarStatus car)
 {
     Debug.Log ("Nitro ! ");
     car.Nitro += nitroValue;
 }
Пример #33
0
 public void Tick()
 {
     switch (Status)
     {
         case CarStatus.Ready:
             Status = CarStatus.Moving;
             break;
         case CarStatus.Moving:
             if (rnd.Next(0, 10000)/100D < Consts.ChanceToCrash)
             {
                 Status = CarStatus.Destroyed;
                 CurrentSpeed = 0;
             }
             else if (rnd.Next(0,99) < Consts.DeccelerateChance)
             {
                 double penalty = (100 - rnd.Next(1, Consts.MaxDeccelerate)) / 100D;
                 CurrentSpeed *= penalty;
             }
             else if (rnd.Next(0, 99) < Consts.BonusAccelerateChance)
             {
                 double bonus = (100 + rnd.Next(1, Consts.MaxAccelerateBonus)) / 100D;
                 CurrentSpeed *= bonus;
             }
             else if (CurrentSpeed < maxSpeed / 2)
             {
                 CurrentSpeed += acceleration;
             }
             else if (CurrentSpeed <= maxSpeed)
             {
                 CurrentSpeed += acceleration * (maxSpeed - CurrentSpeed) / maxSpeed;
             }
             if (CurrentSpeed > MaxSpeed)
                 CurrentSpeed = MaxSpeed;
             break;
     }
 }
Пример #34
0
 public override void Execute(CarStatus car)
 {
     GameObject.Instantiate(prefab, GameObject.Find("ProjectileSpawn").transform.position,  GameObject.Find("ProjectileSpawn").transform.rotation);
 }
Пример #35
0
 public void Finish()
 {
     Status = CarStatus.Finished;
     CurrentSpeed = 0;
 }