IEnumerator ContinueGlidingToTarget(Vector3 target)
    {
        flag_camera_in_use = true;
        float dist_tolerance = .2f; // dunno what this should be yet

        float time_start = Time.time;

        while (Mathf.Abs((transform.position - target).magnitude) > dist_tolerance)
        {
            float time_cur = Time.time;

            /* IMPLEMENTED IN ITS OWN FUNCTION NOW
             * //gets param assuming time diff mapped to [0, duration] then maps to [0, 1] to use as lerp param
             * float orig_value = (time_cur - time_start);
             * float normal = Mathf.InverseLerp(0f, glide_duration, orig_value);
             * float remapped = Mathf.Lerp(0, 1, normal);
             */

            float remapped = Freeman_Utilities.MapValueFromRangeToRange((time_cur - time_start), 0f, glide_duration, 0f, 1f);

            //now we use the lerp param we just calculated
            transform.position = Vector3.Lerp(transform.position, target, remapped);
            yield return(null);
        }
        //we're close enough. Just set the position already!!!!
        transform.position = target;
        flag_camera_in_use = false; //unlock camera movement
    }
    //NOTE: only size operations should lock camera inputs. Size ops should not handle locking camera!
    IEnumerator ContinueInterpolatingCameraSize(float desired_size, float duration)
    {
        flag_camera_size_in_use = true;

        float tolerance  = .1f;
        float time_start = Time.time;

        while (Mathf.Abs(desired_size - cam.orthographicSize) > tolerance)
        {
            float time_cur = Time.time;
            float remapped = Freeman_Utilities.MapValueFromRangeToRange((time_cur - time_start), 0f, glide_duration, 0f, 1f);

            cam.orthographicSize = Mathf.Lerp(cam.orthographicSize, desired_size, remapped);

            yield return(null);
        }
        cam.orthographicSize    = desired_size;
        flag_camera_size_in_use = false;
    }
Exemple #3
0
    //TODO: Broken! fix!
    private void ContinueDisplayingCooldown()
    {
        float bar_width       = 40;
        float bar_width_half  = bar_width / 2;
        float bar_height      = 10;
        float bar_height_half = bar_height / 2;


        Vector3 center_3 = Camera.current.WorldToScreenPoint(transform.position); //why is the y component scaling wrong??????????

        //center_3 *= -1;
        Debug.Log(center_3);

        //cooldown box 1
        GUI.Box(new Rect((center_3.x - bar_width_half), (center_3.y - bar_height_half), bar_width, bar_height), "");

        //dynamic cd box
        float cur = Mathf.Clamp((Time.time - time_since_last_attack), 0, attack_cooldown_current);

        Freeman_Utilities.MapValueFromRangeToRange(cur, 0, attack_cooldown_current, 0, bar_width);

        GUI.Box(new Rect((center_3.x - bar_width_half), (center_3.y - bar_height_half), cur, bar_height), "");
    }
    //assumes ghost material is emmissive AND  transparent. Interpolates both to 0 in given duration
    IEnumerator ContinueRemoveGhostFade(float duration)
    {
        //Debug.Log("Ghost Fade");
        float start_time = Time.time;
        float cur_time   = Time.time;

        MeshRenderer mesh_renderer = ghost_tower.GetComponentInChildren <MeshRenderer>();
        Material     mat           = mesh_renderer.material;

        while (Mathf.Abs(cur_time - start_time) < duration)
        {
            //Interp emmissive
            float t = Freeman_Utilities.MapValueFromRangeToRange(Mathf.Abs(cur_time - start_time), 0f, duration, 0f, 1f);

            mat.Lerp(mat, fully_transparent_ghost_material, t);

            cur_time = Time.time;
            yield return(null);
        }

        //Debug.Log("Ghost Fade Complete");
        RemoveGhost();
    }