Пример #1
0
    public void AttachFishToFloat()
    {
        caughtTime       = Time.time;
        caught           = true;
        transform.parent = floatable.transform;
        Vector3 pos = Vector3.zero;

        pos.z = -(transform.localScale.z * 3.5f);

        transform.localPosition    = pos;
        transform.localEulerAngles = Vector3.zero;

        floatable.PlayFishSplash();
    }
Пример #2
0
    public IEnumerator ReelInFishRoutine()
    {
        fighting = true;
        yield return(null);

        int clicks      = 0;
        int clickTarget = 2;

        float fishScale = floatable.currentFish.transform.lossyScale.z;

        if (fishScale < 0.06f)
        {
            clickTarget = 1;
        }
        else if (fishScale < 0.12f)
        {
            clickTarget = 2;
        }
        else if (fishScale < 0.16f)
        {
            clickTarget = 3;
        }
        else if (fishScale < 0.2f)
        {
            clickTarget = 4;
        }
        else if (fishScale < 0.25f)
        {
            clickTarget = 5;
        }
        else if (fishScale < 0.3f)
        {
            clickTarget = 6;
        }
        else if (fishScale < 0.4f)
        {
            clickTarget = 7;
        }

        float zRotTarget = defaultZRot;

        while ((floatable.currentFish && floatable.currentFish.caught && clicks < clickTarget && floatable.inWater))
        {
            if (Input.GetKeyDown(KeyCode.Mouse0))
            {
                clicks++;

                floatable.PlayFishSplash();

                clicks = Mathf.Clamp(clicks, 0, clickTarget);

                if (clicks > 0)
                {
                    zRotTarget = (float)defaultZRot + (80f * ((float)clicks / (float)clickTarget));
                }
                else
                {
                    zRotTarget = defaultZRot;
                }
            }

            Vector3 targetRot = transform.localEulerAngles;
            targetRot.z = zRotTarget;

            transform.localEulerAngles = Vector3.Lerp(transform.localEulerAngles, targetRot, Time.deltaTime * 5f);

            yield return(null);
        }


        if (floatable.currentFish && floatable.currentFish.caught && (clicks >= clickTarget || !floatable.inWater))
        {
            StartCoroutine(ReelInRoutine());
        }

        fighting = false;
    }