Exemplo n.º 1
0
    public void OnCardAttacking()
    {
        m_VisualizeEffect = new CardAttackEffect();

        CardVisualizeEffectData AttackEffectData = new CardVisualizeEffectData.CardVisualizeEffectAttack(1.0f, 1.0f);

        m_VisualizeEffect.InitVisualizeEffect(gameObject, AttackEffectData);
    }
Exemplo n.º 2
0
    public override IEnumerator UpdateVisualizeEffect()
    {
        if (m_EffectTarget != null)
        {
            if (m_AttackEffectData == null)
            {
                m_AttackEffectData = (CardVisualizeEffectData.CardVisualizeEffectAttack)m_VisualizeEffectData;
            }

            if (m_CurrentElapsedTime < m_AttackEffectData.m_EffectTime)
            {
                float actionExecuteThreshold = m_AttackEffectData.m_EffectTime * 0.3f;
                if (m_CurrentElapsedTime < actionExecuteThreshold)
                {
                    m_VisualizeStatus = VisualizeEffectStatus.Start;
                    float lerpTime         = m_CurrentElapsedTime / actionExecuteThreshold;
                    float lerpedPosition_Y = Mathf.Lerp(m_EffectStartPosition.y, m_EffectStartPosition.y + m_AttackEffectData.m_DistanceToSource, lerpTime);

                    m_EffectTarget.transform.position = new Vector3(m_EffectStartPosition.x, lerpedPosition_Y, m_EffectStartPosition.z);
                }
                else
                {
                    switch (m_VisualizeStatus)
                    {
                    case VisualizeEffectStatus.Start:
                    {
                        m_VisualizeStatus = VisualizeEffectStatus.Execute;
                    }
                    break;

                    case VisualizeEffectStatus.Execute:
                    {
                        m_VisualizeStatus = VisualizeEffectStatus.Progress;
                    }
                    break;

                    default:
                    { }
                    break;
                    }

                    float lerpTime         = m_CurrentElapsedTime / (m_AttackEffectData.m_EffectTime - actionExecuteThreshold);
                    float lerpedPosition_Y = Mathf.Lerp(m_EffectStartPosition.y + m_AttackEffectData.m_DistanceToSource, m_EffectStartPosition.y, lerpTime);

                    m_EffectTarget.transform.position = new Vector3(m_EffectStartPosition.x, lerpedPosition_Y, m_EffectStartPosition.z);
                }
                m_CurrentElapsedTime += Time.deltaTime;
            }
            else
            {
                m_EffectTarget       = null;
                m_CurrentElapsedTime = 0.0f;
                m_VisualizeStatus    = VisualizeEffectStatus.End;
            }
        }

        yield return(null);
    }