示例#1
0
        public async Task <ActionResult <RobotModel> > PostRobotModel(long id)
        {
            var robot = await _context.Robots.FindAsync(id);

            if (robot is null)
            {
                return(NotFound());
            }

            RobotReset robotReset = new RobotReset();

            robotReset.Reset(robot);

            _context.Entry(robot).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

            return(NoContent());
        }
示例#2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        float v = Input.GetAxis("P" + playerNumber + "Yaxis") * motorForce;
        float h = Input.GetAxis("P" + playerNumber + "Xaxis") * motorForce;

        if (Input.GetButtonDown("P" + playerNumber + "X"))
        {
            flip.Pressing(true);
            print("oi");
        }
        else
        {
            flip.Pressing(false);
        }
        if (flip.Full())
        {
            flip.Reset();
            ResetPos();
        }

        if (Vector3.Dot(transform.up, Vector3.down) > 0)
        {
        }
        else
        {
            resetting = false;
            seconds   = Time.fixedTime;
        }

        if (battery.Empty())
        {
            motorForce = 2700;
        }

        if (v <= motorForce && v > motorForce - 1000)
        {
            leftWheel.motorTorque       = -motorForce;
            leftWheelFront.motorTorque  = -motorForce;
            rightWheel.motorTorque      = -motorForce;
            rightWheelFront.motorTorque = -motorForce;

            leftWheel.brakeTorque       = 0;
            rightWheel.brakeTorque      = 0;
            leftWheelFront.brakeTorque  = 0;
            rightWheelFront.brakeTorque = 0;

            battery.Driving(true);
        }
        else if (v >= -motorForce && v < -motorForce + 1000)
        {
            leftWheel.motorTorque       = motorForce;
            leftWheelFront.motorTorque  = motorForce;
            rightWheel.motorTorque      = motorForce;
            rightWheelFront.motorTorque = motorForce;

            leftWheel.brakeTorque       = 0;
            rightWheel.brakeTorque      = 0;
            leftWheelFront.brakeTorque  = 0;
            rightWheelFront.brakeTorque = 0;

            battery.Driving(true);
        }
        else if (h >= -motorForce && h < -motorForce + 1000)
        {
            leftWheel.motorTorque       = motorForce * spinFactor;
            leftWheelFront.motorTorque  = motorForce * spinFactor;
            rightWheel.motorTorque      = -motorForce * spinFactor;
            rightWheelFront.motorTorque = -motorForce * spinFactor;

            leftWheel.brakeTorque       = 0;
            rightWheel.brakeTorque      = 0;
            leftWheelFront.brakeTorque  = 0;
            rightWheelFront.brakeTorque = 0;

            battery.Driving(true);
        }
        else if (h <= motorForce && h > motorForce - 1000)
        {
            leftWheel.motorTorque       = -motorForce * spinFactor;
            leftWheelFront.motorTorque  = -motorForce * spinFactor;
            rightWheel.motorTorque      = motorForce * spinFactor;
            rightWheelFront.motorTorque = motorForce * spinFactor;

            leftWheel.brakeTorque       = 0;
            rightWheel.brakeTorque      = 0;
            leftWheelFront.brakeTorque  = 0;
            rightWheelFront.brakeTorque = 0;

            battery.Driving(true);
        }
        else
        {
            leftWheel.motorTorque       = 0;
            leftWheelFront.motorTorque  = 0;
            rightWheel.motorTorque      = 0;
            rightWheelFront.motorTorque = 0;

            leftWheel.brakeTorque       = brakeForce;
            rightWheel.brakeTorque      = brakeForce;
            leftWheelFront.brakeTorque  = brakeForce;
            rightWheelFront.brakeTorque = brakeForce;

            battery.Driving(false);
        }

        if (Input.GetAxis("P" + playerNumber + "A") > 0)
        {
            leftWheel.brakeTorque       = brakeForce;
            rightWheel.brakeTorque      = brakeForce;
            leftWheelFront.brakeTorque  = brakeForce;
            rightWheelFront.brakeTorque = brakeForce;

            battery.Driving(false);
        }
        else
        {
            leftWheel.brakeTorque       = 0;
            rightWheel.brakeTorque      = 0;
            leftWheelFront.brakeTorque  = 0;
            rightWheelFront.brakeTorque = 0;
        }
    }