Ejemplo n.º 1
0
    void lookAtFood()
    {
        Vector3 foodPosition = food.transform.position;

        float angle    = ((Vector2)(transform.position - foodPosition)).getAngle() * Mathf.Deg2Rad,
              distance = ((Vector2)(transform.position - foodPosition)).magnitude;

        transform.rotation = Quaternion.Euler(0f, 0f, angle * Mathf.Rad2Deg);

        distance /= transform.localScale.x / 2f;

        mouthAngle = Mathf.Lerp(maxMouthAngle, 0f, distance / mouthStartDistance);
        updateMouth();

        bool flipped = foodPosition.x > transform.position.x;

        transform.localScale = new Vector3(1f, flipped ? -1f : 1f, 1f);


        if (distance <= eatRadius)
        {
            food.eaten   = true;
            mouthClosing = true;

            ParticleHelper.setEmissionRate(food.GetComponent <ParticleSystem>(), food.particleRate);

            MicrogameController.instance.setVictory(true, true);
            confettiParticles.Play();

            MicrogameController.instance.playSFX(victoryClip, 0f, 1f, .75f);
        }
    }
Ejemplo n.º 2
0
 void Awake()
 {
     particles      = GetComponent <ParticleSystem>();
     particleRate   = ParticleHelper.getEmissionRate(particles);
     spriteRenderer = GetComponent <SpriteRenderer>();
     ParticleHelper.setEmissionRate(particles, 0f);
 }
Ejemplo n.º 3
0
    void lookAtCursor()
    {
        Vector3 cursorPosition = CameraHelper.getCursorPosition();

        float angle    = MathHelper.getVectorAngle2D((Vector2)(transform.position - cursorPosition)) * Mathf.Deg2Rad,
              distance = ((Vector2)(transform.position - cursorPosition)).magnitude;

        transform.rotation = Quaternion.Euler(0f, 0f, angle * Mathf.Rad2Deg);

        distance /= transform.localScale.x / 2f;

        mouthAngle = Mathf.Lerp(maxMouthAngle, 0f, distance / mouthStartDistance);
        updateMouth();

        bool flipped = cursorPosition.x > transform.position.x;

        if (flipped)
        {
            transform.localScale = new Vector3(1f, -1f, 1f);
        }
        else
        {
            transform.localScale = new Vector3(1f, 1f, 1f);
        }

        if (distance <= eatRadius)
        {
            food.eaten   = true;
            mouthClosing = true;

            ParticleHelper.setEmissionRate(food.GetComponent <ParticleSystem>(), food.particleRate);

            //food.GetComponent<ParticleSystem>().emission.rate = new ParticleSystem.MinMaxCurve(food.particleRate);

            MicrogameController.instance.setVictory(true, true);

            //feedSound.pitch = 1.1f * Time.timeScale;
            //feedSound.Play();

            //CameraController.instance.setShakeCoolRate(0f);
            //CameraController.instance.setScreenShake(1f);
        }
    }