예제 #1
0
    //public void Update() {
    //if (Main.Ins.GameBattleEx != null && Main.Ins.GameBattleEx.BattleFinished())
    //    return;
    //if (CombatData.Ins.Replay && FrameReplay.Instance.Started) {

    //} else {
    //    if (Main.Ins.LocalPlayer != null) {
    //        if (Main.Ins.LocalPlayer.meteorController.InputLocked)
    //            return;
    //    }
    //    getButtons();
    //}
    //getAxis();
    //}

    public void ProcessKey(KeyState keyState)
    {
        Pressed.Clear();
        Released.Clear();
        Pressing.Clear();
        if (keyMapping.ContainsKey(keyState.Key))
        {
            JoyKeyState js  = keyMapping[keyState.Key];
            bool        old = js.PointDown;
            js.PointDown = Input.GetKey(js.key);
            if (old && !js.PointDown)
            {
                Released.Add(js);
            }
            if (!old && js.PointDown)
            {
                Pressed.Add(js);
            }
            if (old && js.PointDown)
            {
                Pressing.Add(js);
            }
            //先按下
            for (int i = 0; i < Pressed.Count; i++)
            {
                if (Pressed[i].OnPress != null)
                {
                    Pressed[i].OnPress.Invoke();
                }
            }
            //再蓄力
            for (int i = 0; i < Pressing.Count; i++)
            {
                if (Pressing[i].OnPressing != null)
                {
                    Pressing[i].OnPressing.Invoke();
                }
            }
            //再弹起
            for (int i = 0; i < Released.Count; i++)
            {
                if (Released[i].OnRelease != null)
                {
                    Released[i].OnRelease.Invoke();
                }
            }
        }
    }