Пример #1
0
    public void TryAction(ActionInfo ai, OnRegisterHit hitCallback = null, InputKey holdInput = InputKey.Fire)
    {
        if (ai == null)
        {
            return;
        }
        if (!canAct())
        {
            return;
        }
        m_currentAction             = ai;
        m_currentAction.m_useButton = holdInput;
        m_currentAction.ClearCallback();
        m_currentAction.AddCallBack(hitCallback);
        m_currentAction.AddCallBack(RegisterHit);
        setAutonomous(ai.m_MovementInfo.CanMove);
        if (ai.m_MovementInfo.CanMove)
        {
            float time = Mathf.Max(0.1f, ai.m_AttackAnimInfo.StartUpTime + ai.m_AttackAnimInfo.RecoveryTime);
            GetComponent <MovementBase>().AddModifier(ai.AttackName, ai.m_MovementInfo.MovementModifier, time);
        }

        //ExecuteEvents.Execute<ICustomMessageTarget>(gameObject, null, (x, y) => x.OnAttack(m_currentAction));
        GetComponent <MovementBase>().DecelerateInAir = false;
        if (m_currentAction != null)
        {
            m_currentAction.ResetAndProgress();
        }
    }