Exemple #1
0
    /// <summary>
    /// 冲刺攻击
    /// </summary>
    /// <param name="_targetPos"></param>
    /// <returns></returns>
    IEnumerator IE_dash(Vector3 _targetPos)
    {
        float   duration    = ((Vector2)(_targetPos - transform.position)).magnitude / dashSpeed;
        float   timer       = 0;
        Vector3 t_Pos_start = transform.position;

        _targetPos.z = t_Pos_start.z;
        //准备
        const float time_ready = 0.5f;

        while (timer < time_ready)
        {
            timer += Time.deltaTime;
            float t = timer / time_ready;

            transform.localScale = Vector3.Lerp(originScale, originScale * 1.4f, GameFunction.smoothLerp(t));

            yield return(null);
        }

        timer = 0;
        while (timer < duration)
        {
            timer += Time.deltaTime;
            float t = timer / duration;

            transform.localScale = Vector3.Lerp(originScale * 1.4f, originScale, GameFunction.smoothLerp(t));
            transform.position   = Vector3.Lerp(t_Pos_start, _targetPos, t);

            yield return(null);
        }

        isAttackFinish = true;
    }
Exemple #2
0
    /// <summary>
    /// 激光动画
    /// </summary>
    /// <returns></returns>
    IEnumerator IE_Laser()
    {
        int   mask     = 1 << LayerMask.NameToLayer("terrain");
        float duration = 0.3f;
        float Timer    = 0;

        //准备
        const float time_ready = 1f;

        while (Timer < time_ready)
        {
            Timer += Time.deltaTime;
            float t = Timer / time_ready;

            SR_heart.color = Color.Lerp(originColor_heart, Color_laser, GameFunction.smoothLerp(t));

            yield return(null);
        }


        Timer = 0;
        yield return(new WaitForSeconds(0.3f));

        Vector3 direction = ((Vector2)(CharacterControl.instance.transform.position - transform.position)).normalized;

        edgeColl.enabled          = true;
        LR.enabled                = true;
        GameFunction.t_Vector3    = transform.position;
        GameFunction.t_Vector3.z += 0.01f;
        LR.SetPosition(0, GameFunction.t_Vector3);
        edgeColl.points = edgePos;
        Vector2 _targetPos;

        SR_laserHit.enabled = true;
        while (Timer < duration)
        {
            Timer += Time.deltaTime;
            float t = Timer / duration;

            SR_heart.color = Color.Lerp(Color_laser, originColor_heart, GameFunction.smoothLerp(t));
            //发射射线
            hitPoint = Physics2D.Raycast(transform.position, direction, 999, mask);
            if (hitPoint.transform != null)
            {
                _targetPos = hitPoint.point;
            }
            else
            {
                _targetPos = transform.position + direction * 999;
            }

            float t_width = Mathf.Lerp(startWidth_laser, 0, t);
            LR.SetWidth(t_width, t_width);
            GameFunction.t_Vector3    = transform.position;
            GameFunction.t_Vector3.z += 0.01f;
            LR.SetPosition(0, GameFunction.t_Vector3);
            GameFunction.t_Vector3    = _targetPos;
            GameFunction.t_Vector3.z += 0.01f;
            edgePos[1]      = transform.InverseTransformPoint(GameFunction.t_Vector3);
            edgeColl.points = edgePos;
            LR.SetPosition(1, GameFunction.t_Vector3);

            laserHit.transform.position = GameFunction.t_Vector3;
            laserHit.localScale         = Vector3.Lerp(originScale_laserHit, Vector3.zero, t - 0.3f);

            yield return(null);
        }
        SR_laserHit.enabled = false;
        isLaser             = false;
        LR.enabled          = false;
        edgeColl.enabled    = false;
        isAttackFinish      = true;
    }