public IActionResult Get(int id)
        {
            //get crash
            if (id > 0)
            {
                var crash = getById(id);

                if (crash != null)
                {
                    return(new OkObjectResult(JsonConvert.SerializeObject(crash, Formatting.None, new JsonSerializerSettings()
                    {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                    })));                                                                                                                                                                  //Loop referencing
                }
                else
                {
                    return(NotFound());
                }
            }
            else
            {
                var crash = new crash();

                return(new OkObjectResult(JsonConvert.SerializeObject(crash, Formatting.None, new JsonSerializerSettings()
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                })));
            }
        }
 private void copydata(crash source, crash target)
 {
     target.companyId      = source.companyId;
     target.crashmeasureId = source.crashmeasureId;
     target.dayhour        = source.dayhour;
     target.isauthorknown  = source.isauthorknown;
     target.isoutofservice = source.isoutofservice;
 }
예제 #3
0
    void moveMap()
    {
        ++actualStep;

        for (int i = 0; i < roadsMap.Length - 1; ++i)        //przesuwanie mapy
        {
            roadsMap[i]       = roadsMap[i + 1];
            roadsDirection[i] = roadsDirection[i + 1];
            stepCounter[i]    = stepCounter[i + 1];
        }
        //generowanie nowego odcinka mapy
        if (roadsMap[13] == 1 && roadsMap[12] == 1 && roadsMap[11] == 1 && roadsMap[10] == 1)
        {
            roadsMap[14] = 0;
        }
        else if (roadsMap[12] == 0 && roadsMap[13] == 0)
        {
            roadsMap[14] = 1;
        }
        else if (roadsMap[12] == 2 && roadsMap[13] == 2)
        {
            roadsMap[14] = 0;
        }
        else
        {
            roadsMap[14] = Random.Range(0, 2);
            if (Random.value > 0.90)
            {
                if (roadsMap[12] != 2 || roadsMap[13] != 2)
                {
                    roadsMap[14] = 2;
                }
            }
        }

        //losowanie kierunków w których się będą poruszać pojazdy
        if (roadsDirection[13] == true)
        {
            roadsDirection[14] = false;
        }
        else
        {
            roadsDirection[14] = true;
        }

        //za ile ma się zrespić kolejne autko
        stepCounter[14] = Random.Range(4, 10);

        if (roadsMap[14] == 1)
        {
            crash newCar = new crash(Random.Range(0, 5), roadsDirection[14], Random.Range(15, 40), (actualStep + 11) * 3);
            vehicle.Add(newCar);
        }
    }
        private void adddetail(crash source, crash target)
        {
            if (source.crashdetail != null && source.crashdetail.Count > 0)
            {
                target.crashdetail = new List <crashdetail>();
            }

            foreach (crashdetail detail in source.crashdetail)
            {
                target.crashdetail.Add(detail);
            }
        }
        public IActionResult Put(int id, [FromBody] crash value)
        {
            var crash = _context.crash.Include(t => t.crashdetail).Where(t => t.crashId == id).FirstOrDefault <crash>();

            if (crash != null)
            {
                copydata(value, crash);

                _context.SaveChanges();

                var send = getById(id);

                return(Ok(send));
            }
            else
            {
                return(NotFound());
            }
        }
        public IActionResult Post([FromBody] crash value)
        {
            var crash = new crash();

            copydata(value, crash);
            adddetail(value, crash);

            _context.crash.Add(crash);
            _context.SaveChanges();

            _logger.LogInformation("Travel post");

            var send = getById(crash.crashId);

            return(new OkObjectResult(JsonConvert.SerializeObject(send, Formatting.None, new JsonSerializerSettings()
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            })));                                                                                                                                                                 //Loop referencing
            //return Ok(send);
        }
예제 #7
0
    void resetGame()
    {
        //postać
        posX = 30;                            //pozycja żabki
        posY = 0;

        yourDirection = 0;           //0 - przód | 1 - tył
        backAnimal    = 0;

        stepTime     = 0.07f;                    //ruchu
        sideAnimTime = 0f;
        sideAnim     = 0;

        actualStep = 5;

        //kamera
        cameraHeight = -3;
        cameraJump   = 1f;                    //czas pomiędzy kolejnym przejściem kamery

        loseMoveTime = 0.2f;
        heightLose   = 22;
        endVehicleID = 0;

        //mapa
        //ustawianie ulic i trawy
        for (int i = 0; i < roadsMap.Length; ++i)
        {
            //ustawianie ulic i trawy
            if (i == 0 || i == 1 || i == 2 || i == 3 || i == 4 || i == 5 || i == 7 || i == 9 || i == 12 || i == 13)
            {
                roadsMap[i] = 0;
            }
            else
            {
                roadsMap[i] = 1;
            }

            //losowanie kierunków w których się będą poruszać pojazdy
            if (i == 0)
            {
                if (Random.value > 0.5f)
                {
                    roadsDirection[i] = false;
                }
                else
                {
                    roadsDirection[i] = true;
                }
            }
            else
            {
                if (roadsDirection[i - 1])
                {
                    roadsDirection[i] = false;
                }
                else
                {
                    roadsDirection[i] = true;
                }
            }

            //za ile ma się zrespić kolejne autko
            stepCounter[i] = Random.Range(8, 15);
        }

        //mechanika
        for (int i = 0; i < vehicle.Count;)        //niszczenie wszystkich aut
        {
            vehicle.RemoveAt(i);
        }
        for (int i = 0; i < train.Count;)        //niszczenie wszystkich pociągów
        {
            train.RemoveAt(i);
        }
        menu           = false;
        lose           = false;
        HRTM.score     = 0;
        HRTM.firstFeil = true;

        //wstepne autka
        for (int b = 5; b < roadsMap.Length; ++b)
        {
            if (roadsMap[b] == 1)
            {
                crash newCar = new crash(Random.Range(0, 5), roadsDirection[b], Random.Range(20, 40), (actualStep + b - 10) * 3);
                vehicle.Add(newCar);
            }
        }
    }
예제 #8
0
    //==============================koniec sterowania=================================

    int randVehicles(int road, int type)
    {
        int tempPosY = (road + actualStep - 10) * 3;
        int tempPosX = 0;

        int tempType  = Random.Range(0, 5);
        int tempWidth = 0;

        if (tempType == 0)
        {
            tempWidth = 4;
        }
        else if (tempType == 1)
        {
            tempWidth = 8;
        }
        else if (tempType == 2)
        {
            tempWidth = 8;
        }
        else if (tempType == 3)
        {
            tempWidth = 8;
        }
        else if (tempType == 4)
        {
            tempWidth = 13;
        }

        if (roadsDirection[road])
        {
            tempPosX = 63;
        }
        else
        {
            tempPosX = (-tempWidth) - 1;
        }

        if (type == 1)        //auto
        {
            crash newCar = new crash(tempType, roadsDirection[road], tempPosX, tempPosY);
            vehicle.Add(newCar);
        }
        else         //pociąg
        {
            if (roadsDirection[road])
            {
                tempPosX = 70;

                crash newTrain = new crash(5, roadsDirection[road], tempPosX, tempPosY);
                train.Add(newTrain);
                tempPosX += 11;
                newTrain  = new crash(6, roadsDirection[road], tempPosX, tempPosY);
                train.Add(newTrain);
                for (int p = 0; p < 5; ++p)
                {
                    tempPosX += 15;
                    newTrain  = new crash(6, roadsDirection[road], tempPosX, tempPosY);
                    train.Add(newTrain);
                }
            }
            else
            {
                tempPosX = -5;

                crash newTrain = new crash(5, roadsDirection[road], tempPosX, tempPosY);
                train.Add(newTrain);
                tempPosX -= 11;
                newTrain  = new crash(6, roadsDirection[road], tempPosX, tempPosY);
                train.Add(newTrain);
                for (int p = 0; p < 5; ++p)
                {
                    tempPosX -= 15;
                    newTrain  = new crash(6, roadsDirection[road], tempPosX, tempPosY);
                    train.Add(newTrain);
                }
            }
            return(0);
        }

        return(vehicle[vehicle.Count - 1].width);
    }