コード例 #1
0
    private void Update()
    {
        if (Input.GetKey(KeyCode.UpArrow))
        {
            shipSpeed += ship.ShipAcceleration;
            engine.SetVelocity(shipSpeed);
        }

        if (Input.GetKey(KeyCode.DownArrow))
        {
            shipSpeed -= ship.ShipAcceleration;
            engine.SetVelocity(shipSpeed);
        }

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            Quaternion newRotation = transform.rotation * Quaternion.Euler(0f, 0f, ship.ShipRotationSpeed);
            engine.SetRotation(newRotation);
        }

        if (Input.GetKey(KeyCode.RightArrow))
        {
            Quaternion newRotation = transform.rotation * Quaternion.Euler(0f, 0f, -ship.ShipRotationSpeed);
            engine.SetRotation(newRotation);
        }

        if (Input.GetKeyDown(KeyCode.H))
        {
            ship.SpawnPlane();
        }
    }
コード例 #2
0
    void Update()
    {
        engine.SetVelocity(CalculateVelocity());
        engine.SetRotation(CalculateRotation());

        if (!isLanding)
        {
            flightTimer += Time.deltaTime;
            if (flightTimer > maxFlightTime)
            {
                float landingTime = Utils.FindReturnTime(planeRadius, Utils.GetMiddleValue(minSpeed, maxSpeed));
                LandingSignal(landingTime);
                isLanding = true;
            }
        }
    }