// Update is called once per frame
    void Update()
    {
        float   joystickX   = controls.getLeftStickX();
        float   joystickY   = controls.getLeftStickY();
        Vector3 joystickVec = new Vector3(joystickX, joystickY, 0);

        if (joystickVec != Vector3.zero)
        {
            transform.up = joystickVec * -1f;
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        //if (controls.getADown()) {
        //    transform.parent.gameObject.GetComponent<PlayerController>().destroyEntireTrail();
        //    Camera.main.GetComponent<Shake>().shakeDuration = 0.5f;

        //}

        if (controls.getLeftTriggerDown())
        {
            Debug.Log("Drawing??");
            GameObject line = Instantiate(linePrefab);
            activeLine = line.GetComponent <Line>();
            activeLine.SetOwner(transform.parent.GetComponent <PlayerController>().GetPlayerNumber());
        }
        if (controls.getLeftTriggerUp())
        {
            activeLine = null;
        }
        if (activeLine != null)
        {
            activeLine.UpdateLine(transform.position);
        }
        float   joystickX   = controls.getLeftStickX();
        float   joystickY   = controls.getLeftStickY();
        Vector3 joystickVec = new Vector3(joystickX, joystickY, 0);
        Vector3 ballVec     = transform.position - transform.parent.position;

        angle = Vector2.Angle(joystickVec, ballVec);
        if (angle >= 30)
        {
            lerpFract = 0.3f;
        }
        else
        {
            lerpFract = 0.4f;
        }
        cursorPos = Vector3.Lerp(transform.position - transform.parent.position, joystickVec, lerpFract);
        //Vector2 offset = (Vector2)cursorPos - (Vector2)transform.parent.position; //HERE'S THE PROBLEM
        cursorPos.Normalize();
        //offset.Normalize();
        //offset = offset * radius;
        cursorPos = cursorPos * radius;
        transform.localPosition = cursorPos;
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        float   joystickX   = controls.getLeftStickX();
        float   joystickY   = controls.getLeftStickY();
        Vector3 joystickVec = new Vector3(joystickX, joystickY, 0);
        Vector3 ballVec     = transform.position - transform.parent.position;

        angle = Vector2.Angle(joystickVec, ballVec);
        if (angle >= 30)
        {
            lerpFract = 0.4f;
        }
        else
        {
            lerpFract = 0.6f;
        }
        // Debug.Log("Angle: " + angle + ", LerpFract: " + lerpFract);
        cursorPos = Vector3.Lerp(transform.position, joystickVec, lerpFract); //CHANGE MOUSE TO CONTROLLER INPUT
        Vector2 offset = (Vector2)cursorPos - Vector2.zero;

        offset.Normalize();
        offset             = offset * radius;
        transform.position = offset;
    }
    IEnumerator displayTutorialButtons()
    {
        yield return(new WaitForSeconds(2));

        StartCoroutine(FadeOut(fader));
        yield return(new WaitForSeconds(3));

        //Spawn in Trigger button prompt
        StartCoroutine(FadeIn(triggerPrompt));
        yield return(new WaitUntil(() => controls.getRightTriggerDown()));

        //Change color of trigger button prompt
        yield return(new WaitForSeconds(4));

        //Spawn in Analog stick prompt
        yield return(new WaitForSeconds(1));

        StartCoroutine(FadeIn(analogPrompt));
        yield return(new WaitUntil(() => controls.getRightTrigger() && (controls.getLeftStickX() > Mathf.Abs(0.5f) || controls.getLeftStickY() > Mathf.Abs(0.5f))));

        //Change color of analog stick prompt
        yield return(new WaitForSeconds(10));

        StartCoroutine(FadeOut(triggerPrompt));
        StartCoroutine(FadeOut(analogPrompt));
        yield return(new WaitForSeconds(1));

        StartCoroutine(FadeIn(neuronPrompt));
        yield return(new WaitForSeconds(3));

        neuron.SetActive(true);
        //Spawn in start button
        yield return(new WaitUntil(() => neuron.GetComponent <Neuron>().activated));

        StartCoroutine(FadeOut(neuronPrompt));
        yield return(new WaitForSeconds(3));

        StartCoroutine(FadeIn(startPrompt));
        yield return(new WaitUntil(() => controls.getADown()));

        StartCoroutine(FadeIn(fader));
        yield return(new WaitForSeconds(2));

        SceneManager.LoadScene(2);



        yield return(null);
    }
    // Update is called once per frame
    void Update()
    {
        bool stunned = transform.parent.GetComponent <PlayerController>().stunned;

        if (stunned || paused)
        {
            AkSoundEngine.PostEvent("Set_State_Surfing_Off", gameObject);
        }
        if (!paused && !stunned)
        {
            //if (controls.getADown()) {
            //    transform.parent.gameObject.GetComponent<PlayerController>().destroyEntireTrail();
            //    Camera.main.GetComponent<Shake>().shakeDuration = 0.5f;

            //}

            if (softLine != null)
            {
                softLine.UpdateLine(transform.position);
                List <Vector2> points = softLine.GetPoints();
                if (points.Count > 0)
                {
                    for (int i = 0; i < points.Count - 10; i++)
                    {
                        if (Vector2.Distance(points[points.Count - 1], points[i]) < 0.5f && !circleDrawn)
                        {
                            circleDrawn = true;
                            softLine.GetComponent <SoftLine>().NeuronCircled(transform.position, transform.up);
                            Debug.Log("Circle Drawn!");
                            circleDrawn = false;
                        }
                    }
                }
            }

            if (controls.getRightTriggerDown()) //generating a few false positives at first
            {
                //Debug.Log("Drawing??");
                player.destroyEntireTrail();
                GameObject line = Instantiate(linePrefab);
                activeLine = line.GetComponent <Line>();
                AkSoundEngine.PostEvent("Set_State_Surfing_On", gameObject);

                LightOn();
            }
            if (controls.getRightTriggerUp())
            {
                activeLine = null;
                AkSoundEngine.PostEvent("Set_State_Surfing_Off", gameObject);

                LightOff();
            }
            if (activeLine != null)
            {
                activeLine.UpdateLine(transform.position);
            }
            float joystickX = controls.getLeftStickX();
            float joystickY = controls.getLeftStickY();
            if (joystickX == 0)
            {
                joystickX = -1;
            }
            Vector3 joystickVec = new Vector3(joystickX, joystickY, 0);
            Vector3 ballVec     = transform.position - transform.parent.position;
            angle = Vector2.Angle(joystickVec, ballVec);
            if (angle >= 30)
            {
                lerpFract = 0.2f;
            }
            else
            {
                lerpFract = 0.4f;
            }
            cursorPos = Vector3.Lerp(transform.position - transform.parent.position, joystickVec, lerpFract);
            cursorPos.Normalize();
            cursorPos = cursorPos * radius;
            transform.localPosition = cursorPos;
        }
    }