Long Press(长按功能)

1.实现长按功能:当用户按下后0.1s内不会有变化,0.1s后变化然后和普通按同时还原。如下图(橘黄色IsDelaying区域为长按,红色为正常按击,紫色区域为判断双击区域)
Long Press(长按功能)增加MyButton代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MyButton {
    /// <summary>
    /// 三种状态(缺省为false)
    /// </summary>
    public bool IsPressing = false;
    public bool OnPressed = false;
    public bool OnReleased = false;
    public bool IsExtending = false;//判断双击区域
    public bool IsDelaying = false;

    public float extendingDuration = 1.0f;//双击判断区域时常
    public float delayingDuration = 1.0f;//长按时间时长

    private bool curState = false;      //目前的状态
    private bool lastState = false;     //前一次状态

    private MyTimer extTimer = new MyTimer();
    private MyTimer delayTimer = new MyTimer();

    public void Tick(bool input)
    {
       // StartTimer(extTimer, 1.0f);
        extTimer.Tick();//推进
        delayTimer.Tick();

        curState = input;

        IsPressing = curState;

        OnPressed = false;
        OnReleased = false;
        IsExtending = false;
        IsDelaying = false;

        if (curState != lastState)
        {
            if(curState ==true )
            {
                OnPressed = true;
                StartTimer(delayTimer, delayingDuration);
              
            }
            else
            {
                OnReleased = true;
                StartTimer(extTimer, extendingDuration);
            }
        }
        lastState = curState;

        if (extTimer.state == MyTimer.STATE.RUN)
        {
            IsExtending = true;
        }
        if(delayTimer.state == MyTimer.STATE.RUN)
        {
            IsDelaying = true;
        }
     


    }
    private void  StartTimer(MyTimer timer,float duration)
    {
        timer.duration = duration;
        timer.Go();
    }
}

修改joystickinput:

 run =( buttonA.IsPressing&& !buttonA.IsDelaying) || buttonA.IsExtending ;
        jump = buttonA.OnPressed&&buttonA .IsExtending;

新增roll判断条件:
IUserInput:增加publick bool roll
有了roll判断条件的时候ground到roll动画的判断条件就要进行修改(只要一个roll判断);ground到jab的判断也只需要一个roll;在切换jab的时候增加时间判断当forward小于0.1的时候是后跳jab;这样实现了没有方向的时候是后跳而有方向的时候会是翻滚。