Ejemplo n.º 1
0
 public bool OnKeyDown(KeyState k)
 {
     if (KeyInput.Length <= state || state < 0)
     {
         return(false);
     }
     if (k.Key == KeyInput[state])
     {
         Pressing = EKeyList.KL_None;
         state++;
         if (state == totalState)
         {
             int target = -1;
             if (Check(out target))
             {
                 mOwner.ActionMgr.LinkAction(target);
                 return(true);
             }
             else
             {
                 Reset();
             }
         }
         else
         {
             frame = Main.Ins.AppInfo.LinkDelay();
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
    public void Register(EKeyList ek, KeyCode k)
    {
        GameStateMgr.Ins.gameStatus.UseGamePad = true;
        List <EKeyList> Keys = new List <EKeyList>();

        foreach (var each in GameStateMgr.Ins.gameStatus.KeyMapping)
        {
            Keys.Add(each.Key);
        }
        for (int i = 0; i < Keys.Count; i++)
        {
            if (GameStateMgr.Ins.gameStatus.KeyMapping[Keys[i]] == k)
            {
                GameStateMgr.Ins.gameStatus.KeyMapping[Keys[i]] = KeyCode.None;
            }
        }

        GameStateMgr.Ins.gameStatus.KeyMapping[ek] = k;
        if (!enabled)
        {
            enabled = true;//触发onenable
        }
        else
        {
            Sync();//主动同步.
        }
    }
Ejemplo n.º 3
0
 public void ReceiveInput(EKeyList key)
 {
     if (HasInput())
     {
         UnityEngine.Debug.Log("error");
         InputKeys.Add(new AIVirtualInput(key));
     }
 }
Ejemplo n.º 4
0
 public void RemovePressing(EKeyList key)
 {
     for (int i = 0; i < inputs.Count; i++)
     {
         if (inputs[i].Pressing == key)
         {
             inputs[i].Reset();
         }
     }
 }
Ejemplo n.º 5
0
 void RegisterInternal(EKeyList ek, KeyCode k)
 {
     if (keyMapping.ContainsKey(ek))
     {
         keyMapping[ek].key = k;
     }
     else
     {
         keyMapping.Add(ek, new JoyKeyState(k));
     }
 }
Ejemplo n.º 6
0
 public void OnKeyPressing(KeyState k)
 {
     if (state == 0)
     {
         if (k.Key == KeyInput[state])
         {
             state++;
             Pressing = k.Key;//等待蓄力招式后续输入
             frame    = Main.Ins.AppInfo.LinkDelay();
         }
     }
 }
Ejemplo n.º 7
0
    //闪亮显示一个要设置的按键.当按下任意一个按键时,与对应的动作绑定.
    public void FlashButton(Button btn, EKeyList vkey, string format)
    {
        if (flashing)
        {
            KillFade();
        }
        flashButton  = btn;
        formatString = format;
        flashKey     = vkey;
        flashing     = true;

        initializeColor = flashButton.GetComponent <Image>().color;
        MyPingPong(flashButton.GetComponent <Image>(), initializeColor, Color.white, 0.5f);
    }
Ejemplo n.º 8
0
        //--------------------------------------------------------------------------------------
        bool checkInputType(EKeyList inpuKey, EInputType inputType, float deltaTime)
        {
            int   pressed      = KeyStates[(int)inpuKey].Pressed;
            float pressedTime  = KeyStates[(int)inpuKey].PressedTime;
            float releasedTime = KeyStates[(int)inpuKey].ReleasedTime;

            bool ret = false;

            switch (inputType)
            {
            case EInputType.EIT_Click:
                ret = (pressedTime == 0);
                break;

            case EInputType.EIT_DoubleClick:
                ret = (pressed == 2 && pressedTime == 0);
                break;

            case EInputType.EIT_Press:
                ret = (pressed != 0 && (pressedTime < LongPressedTime && pressedTime + deltaTime >= LongPressedTime));
                break;

            case EInputType.EIT_Release:
                ret = (pressed == 0 && releasedTime == 0);
                break;

            case EInputType.EIT_Pressing:
                ret = (pressed != 0);
                break;

            case EInputType.EIT_Releasing:
                ret = (pressed == 0);
                break;
            }
            return(ret);
        }
Ejemplo n.º 9
0
 public void PushKeyEvent(MeteorMsg.Command command, int playerId, EKeyList key)
 {
     //GameFrames t = GetFrame(FrameReplay.Instance.NextTurn);
     //for (int i = 0; i < t.commands.Count; i++)
     //{
     //    if ((t.commands[i].command == MeteorMsg.Command.KeyDown ||
     //        t.commands[i].command == MeteorMsg.Command.KeyUp ||
     //        t.commands[i].command == MeteorMsg.Command.KeyLast) &&
     //        playerId == t.commands[i].playerId &&
     //        t.commands[i].LogicFrame == (uint)FrameReplay.Instance.LogicFrameIndex &&
     //        (uint)key == (uint)t.commands[i].data[0])
     //    {
     //        //Debug.LogError("同一帧同一个按键无法响应2次???");
     //        return;
     //    }
     //}
     //FrameCommand cmd = new FrameCommand();
     //cmd.command = command;
     //cmd.LogicFrame = (uint)FrameReplay.Instance.LogicFrameIndex;
     //cmd.playerId = (uint)playerId;
     //cmd.data = new byte[1];
     //cmd.data[0] = (byte)key;
     //t.commands.Add(cmd);
 }
Ejemplo n.º 10
0
 public void OnKeyUp(EKeyList key)
 {
     OnKeyUp(KeyStates[(int)key]);
 }
Ejemplo n.º 11
0
 public void OnKeyDown(EKeyList key)
 {
     OnKeyDown(KeyStates[(int)key]);
 }
Ejemplo n.º 12
0
 public void Reset()
 {
     state    = 0;
     frame    = Main.Ins.AppInfo.LinkDelay();
     Pressing = EKeyList.KL_None;
 }
Ejemplo n.º 13
0
 public void PushKeyDown(int playerId, EKeyList key)
 {
     PushKeyEvent(MeteorMsg.Command.KeyDown, playerId, key);
 }