コード例 #1
0
    public override void OnFixedUpdate()
    {
        rocket.Decelerate();
        Vector3 direction = rocket.GetMovement();

        rocket.Move(direction.x, direction.y);


        bool          nearPlanet = false;
        List <Planet> planets    = planetGenerator.GetPlanets();

        foreach (Planet planet in planets)
        {
            float planetDistance = planet.GetDistance(rocket);
            if (planetDistance <= 0f)
            {
                if (rocket.GetVelocity() >= rocket.crashVelocity)
                {
                    CrashRocket();
                }
                else
                {
                    rocket.Move(-direction.x, -direction.y);
                    rocket.SetVelocity(0);
                }
            }
            else if (planetDistance <= rocket.landDistance && rocket.GetVelocity() < rocket.crashVelocity)
            {
                // Land on planet achievable
                landablePlanet = planet;
                nearPlanet     = true;
            }
        }

        if (nearPlanet == true)
        {
            inputHandler.inputUse = EnterPlanet;
        }
        else
        {
            inputHandler.inputUse = inputHandler.DoNothing;
            landablePlanet        = null;
        }
    }