示例#1
0
    IEnumerator Aim(GameObject selected)
    {
        Bouncer   selectedBouncer = selected.GetComponent <Bouncer>();
        Transform selectedOrigin;

        Vector3 lookAngle;
        float   aimStrength = 0f;

        selectedBouncer.EnableAimReticule(true);
        selectedBouncer.aiming = true;

        while (!Input.GetMouseButtonUp(0))
        {
            selectedOrigin = selected.GetComponent <Transform>();

            //Face select to opposite of mouse
            lookAngle = -(getMousePointInWorld() - selectedOrigin.position);
            selectedOrigin.LookAt(new Vector3(lookAngle.x * 100f, selectedOrigin.position.y, lookAngle.z * 100f));

            //Creating a float to lock the max pull based on stamina allowance
            float maxPullAllowByStamina = Mathf.Clamp(selectedBouncer.stamina.currentValue / gameSettings.maxAttackPower, 0f, 1f);
            //Change aim reticule size and set aim strength
            aimStrength = Mathf.Clamp(Vector3.Distance(getMousePointInWorld(), selectedOrigin.position) / gameSettings.maxPullDistance, 0f, maxPullAllowByStamina);
            selectedBouncer.AdjustAimReticuleSizeAndColor(aimStrength);

            yield return(null);
        }

        //Release attack
        selectedBouncer.LaunchBouncer(aimStrength);
        selectedBouncer.EnableAimReticule(false);
        selectedBouncer.aiming = false;
    }