Пример #1
0
 private void CheckKeyboard(KeyStatus target,KeyCode key)
 {
     target.IsDown = Input.GetKey(key);
     target.IsPressed = Input.GetKeyDown(key);
     target.IsReleased = Input.GetKeyUp(key);
 }
        //private async Task KeepButtonAsync(KeyStatus key, int time)
        //{
        //    key.IsPressed = false;
        //    key.IsDown = true;
        //    await Task.Delay(time);
        //    key.IsDown = false;
        //    key.IsReleased = true;
        //}
        //private void ReleaseButton(KeyStatus key)
        //{
        //    key.IsPressed = false;
        //    key.IsDown = false;
        //    key.IsReleased = true;
        //}

        private void ClearButton(KeyStatus key)
        {
            key.IsPressed = false;
            key.IsDown = false;
            key.IsReleased = false;
        }
        private async Task RepeatButtonAsync(KeyStatus key, int frame,int interval,int count)
        {

            await this.PressButtonAsync(key, frame);

            for (int i = 1; i < count; i++)
            {
                await Task.Delay(interval);
                await this.PressButtonAsync(key, frame);
            }
        }
        private async Task PressButtonAsync(KeyStatus key, int frame)
        {
            key.IsPressed = true;
            key.IsDown = true;
            key.IsReleased = false;

            await this.Frame.Take(1);

            if (frame > 1)
            {
                key.IsPressed = false;
                key.IsDown = true;
                key.IsReleased = false;

                await this.Frame.Take(frame);
            }

            key.IsPressed = false;
            key.IsDown = false;
            key.IsReleased = true;

            await this.Frame.Take(1);

            key.IsReleased = false;


        }
Пример #5
0
        internal KeyInputStatus()
        {
            this.Buttons = Enumerable.Range(0, 4).Select(_ => new KeyStatus()).ToArray();
            this.Up = new KeyStatus();
            this.Down = new KeyStatus();
            this.Left = new KeyStatus();
            this.Right = new KeyStatus();

        }