Esempio n. 1
0
    // Use this for initialization
    public void Init()
    {
        // position the plane at the start point
        GameObject start = GameObject.FindGameObjectWithTag("Start");

        rotValSlider   = GameObject.FindGameObjectWithTag("PlaneRotationSlider").GetComponent <Slider>();
        powerValSlider = GameObject.FindGameObjectWithTag("PlaneThrowPowerSlider").GetComponent <Slider>();
        flyButton      = GameObject.FindGameObjectWithTag("GameController").GetComponent <Button>();
        planeHolder    = GameObject.FindGameObjectWithTag("PlaneHolder");

        fpScript = Camera.main.GetComponent <FlyingPaper>();

        planeStartPosition = new Vector3(start.transform.position.x - 3, start.transform.position.y - 4, 2.5f);
        planeStartRotation = gameObject.transform.rotation;

        gameObject.transform.position = planeStartPosition;

        holderStartPosition = planeHolder.transform.position;
        holderStartRotation = planeHolder.transform.rotation;

        fpScript.SetStartPosition(holderStartPosition, planeStartPosition);
        fpScript.SetStartRotation(holderStartRotation, planeStartRotation);

        rb = this.GetComponent <Rigidbody>();

        rb.constraints = RigidbodyConstraints.FreezeAll;
        finished       = false;


        _sensitivity = 0.6f;
        _rotation    = Vector3.zero;

        RotatePlaneWithSlider();
    }
Esempio n. 2
0
    // Use this for initialization
    void Awake()
    {
        // position the plane at the start point
        GameObject start = GameObject.FindGameObjectWithTag("Start");

        rotValSlider   = GameObject.FindGameObjectWithTag("PlaneRotationSlider").GetComponent <Slider>();
        powerValSlider = GameObject.FindGameObjectWithTag("PlaneThrowPowerSlider").GetComponent <Slider>();
        flyButton      = GameObject.FindGameObjectWithTag("GameController").GetComponent <Button>();
        planeHolder    = GameObject.FindGameObjectWithTag("PlaneHolder");

        fpScript = Camera.main.GetComponent <FlyingPaper>();

        planeStartPosition = new Vector3(start.transform.position.x - 3, start.transform.position.y - 4, 2.5f);
        planeStartRotation = gameObject.transform.rotation;

        gameObject.transform.position = planeStartPosition;

        holderStartPosition = planeHolder.transform.position;
        holderStartRotation = planeHolder.transform.rotation;

        fpScript.SetStartPosition(holderStartPosition, planeStartPosition);
        fpScript.SetStartRotation(holderStartRotation, planeStartRotation);

        rb = this.GetComponent <Rigidbody>();

        rb.constraints = RigidbodyConstraints.FreezeAll;
        finished       = false;

        rotValSlider.value   = 0f;
        powerValSlider.value = 0;

        rotValSlider.GetComponentInChildren <Slider>().onValueChanged.AddListener(delegate { RotatePlaneWithSlider(); });
        powerValSlider.GetComponentInChildren <Slider>().onValueChanged.AddListener(delegate { ChangePlaneThrowSpeed(); });
        flyButton.GetComponentInChildren <Button>().onClick.AddListener(delegate { BeginFlight(); });
    }