Exemple #1
0
    public void ResetValues()
    {
        curr_scene = SceneManager.GetActiveScene().name;
        Cannon cannon = FindObjectOfType <Cannon>();

        Camera cam        = Camera.main;
        float  halfHeight = cam.orthographicSize;
        float  halfWidth  = cam.aspect * halfHeight;

        if (curr_scene == "PM Distance")
        {
            angleInput.interactable = true;
            ivInput.interactable    = true;

            angleInput.text         = GenAngle(10, 80);
            angleInput.interactable = false;
            cannon.FixAngle();

            ivInput.text         = Random.Range(5, 14).ToString();
            ivInput.interactable = false;
        }

        else if (curr_scene == "PM IV")
        {
            distanceInput.interactable = true;
            angleInput.interactable    = true;

            angleInput.text         = GenAngle(10, 80);
            angleInput.interactable = false;
            cannon.FixAngle();

            distanceInput.text         = Random.Range(halfWidth - 0.64f, halfWidth * 2 - 1f).ToString();
            distanceInput.interactable = false;
            cannon.FixPosition();
        }

        else if (curr_scene == "PM Angle")
        {
            distanceInput.interactable = true;
            ivInput.interactable       = true;

            // The -.3f part is so that the whole projectile stays in.
            // Should make a reference to the projectile's width.
            distanceInput.text         = Random.Range((halfWidth - 0.64f), (halfWidth * 2 - 1f)).ToString();
            distanceInput.interactable = false;
            cannon.FixPosition();

            ivInput.text         = Random.Range(5, 14).ToString();
            ivInput.interactable = false;
        }
    }