Inheritance: System.EventArgs
示例#1
0
        private void Instance_GameInputReceived(GameInputEventArgs e)
        {
            var dict = Paused ? backupKeys : activeKeys;

            dict[e.Input] = e.Pressed;

            if (!Paused && !Parent.Paused)
            {
                switch (e.Input)
                {
                case GameInput.Shoot:
                    Shoot = e.Pressed;
                    break;

                case GameInput.Jump:
                    Jump = e.Pressed;
                    break;

                case GameInput.Start:
                    StartKey = e.Pressed;
                    break;

                case GameInput.Select:
                    Select = e.Pressed;
                    break;
                }
            }
        }
示例#2
0
 protected override void GameInputReceived(GameInputEventArgs e)
 {
     if (waiting)
     {
         if (e.Input == GameInput.Shoot || e.Input == GameInput.Jump || e.Input == GameInput.Start)
         {
             waiting = false;
         }
     }
     else if (info.CanSkip && e.Pressed && e.Input == GameInput.Start)
     {
         Finish(info.NextHandler);
     }
 }
示例#3
0
 protected override void GameInputReceived(GameInputEventArgs e)
 {
     if (waiting)
     {
         if (e.Input == GameInput.Shoot || e.Input == GameInput.Jump || e.Input == GameInput.Start)
         {
             waiting = false;
         }
     }
     else if (info.CanSkip && e.Pressed && e.Input == GameInput.Start)
     {
         Finish(info.NextHandler);
     }
 }
示例#4
0
 protected abstract void GameInputReceived(GameInputEventArgs e);
示例#5
0
 protected abstract void GameInputReceived(GameInputEventArgs e);
示例#6
0
        protected override void GameInputReceived(GameInputEventArgs e)
        {
            if (!e.Pressed)
            {
                return;
            }

            int id  = selectedId;
            int min = int.MaxValue;

            if (e.Input == GameInput.Start)
            {
                var select = this.options[selectedId].SelectEvent;
                if (select != null)
                {
                    RunCommands(select);
                }
            }
            else if (e.Input == GameInput.Down)
            {
                for (var i = 0; i < options.Count; i++)
                {
                    if (i == selectedId)
                    {
                        continue;
                    }

                    var info = options[i];

                    int ydist = info.Y - currentPos.Y;
                    if (ydist == 0)
                    {
                        continue;
                    }

                    if (ydist < 0)
                    {
                        ydist += Game.CurrentGame.PixelsDown;               // wrapping around bottom
                    }
                    // weight x distance worse than y distance
                    int dist = 2 * Math.Abs(info.X - currentPos.X) + ydist;
                    if (dist < min)
                    {
                        min = dist;
                        id  = i;
                    }
                }
            }
            else if (e.Input == GameInput.Up)
            {
                for (var i = 0; i < options.Count; i++)
                {
                    if (i == selectedId)
                    {
                        continue;
                    }

                    var info  = options[i];
                    int ydist = currentPos.Y - info.Y;
                    if (ydist == 0)
                    {
                        continue;
                    }

                    if (ydist < 0)
                    {
                        ydist += Game.CurrentGame.PixelsDown;               // wrapping around bottom
                    }
                    // weight x distance worse than y distance
                    int dist = 2 * Math.Abs(info.X - currentPos.X) + ydist;
                    if (dist < min)
                    {
                        min = dist;
                        id  = i;
                    }
                }
            }
            else if (e.Input == GameInput.Right)
            {
                for (var i = 0; i < options.Count; i++)
                {
                    if (i == selectedId)
                    {
                        continue;
                    }

                    var info  = options[i];
                    int xdist = info.X - currentPos.X;
                    if (xdist == 0)
                    {
                        continue;
                    }

                    if (xdist < 0)
                    {
                        xdist += Game.CurrentGame.PixelsAcross;               // wrapping around bottom
                    }
                    int dist = 2 * Math.Abs(info.Y - currentPos.Y) + xdist;
                    if (dist < min)
                    {
                        min = dist;
                        id  = i;
                    }
                }
            }
            else if (e.Input == GameInput.Left)
            {
                for (var i = 0; i < options.Count; i++)
                {
                    if (i == selectedId)
                    {
                        continue;
                    }

                    var info  = options[i];
                    int xdist = currentPos.X - info.X;
                    if (xdist == 0)
                    {
                        continue;
                    }

                    if (xdist < 0)
                    {
                        xdist += Game.CurrentGame.PixelsAcross;               // wrapping around bottom
                    }
                    int dist = 2 * Math.Abs(info.Y - currentPos.Y) + xdist;
                    if (dist < min)
                    {
                        min = dist;
                        id  = i;
                    }
                }
            }

            if (id != selectedId)
            {
                SelectOption(id);
            }
        }
        private void Instance_GameInputReceived(GameInputEventArgs e)
        {
            var dict = Paused ? backupKeys : activeKeys;

            dict[e.Input] = e.Pressed;
            globalKeys[e.Input] = e.Pressed;

            if (!Paused && !Parent.Paused)
            {
                switch (e.Input)
                {
                    case GameInput.Shoot:
                        Shoot = e.Pressed;
                        break;

                    case GameInput.Jump:
                        Jump = e.Pressed;
                        break;

                    case GameInput.Start:
                        StartKey = e.Pressed;
                        break;

                    case GameInput.Select:
                        Select = e.Pressed;
                        break;
                }
            }
        }
示例#8
0
 protected override void GameInputReceived(GameInputEventArgs e)
 {
     if (updateFunc == null || (Player.GetComponent<InputComponent>()).Paused) return;
 }
示例#9
0
文件: Menu.cs 项目: laazer/cs_megaman
        protected override void GameInputReceived(GameInputEventArgs e)
        {
            if (!e.Pressed) return;

            int id = selectedId;
            int min = int.MaxValue;

            if (e.Input == GameInput.Start)
            {
                var select = this.options[selectedId].SelectEvent;
                if (select != null)
                {
                    RunCommands(select);
                }
            }
            else if (e.Input == GameInput.Down)
            {
                for (var i = 0; i < options.Count; i++)
                {
                    if (i == selectedId) continue;

                    var info = options[i];

                    int ydist = info.Y - currentPos.Y;
                    if (ydist == 0) continue;

                    if (ydist < 0) ydist += Game.CurrentGame.PixelsDown;    // wrapping around bottom

                    // weight x distance worse than y distance
                    int dist = 2 * Math.Abs(info.X - currentPos.X) + ydist;
                    if (dist < min)
                    {
                        min = dist;
                        id = i;
                    }
                }
            }
            else if (e.Input == GameInput.Up)
            {
                for (var i = 0; i < options.Count; i++)
                {
                    if (i == selectedId) continue;

                    var info = options[i];
                    int ydist = currentPos.Y - info.Y;
                    if (ydist == 0) continue;

                    if (ydist < 0) ydist += Game.CurrentGame.PixelsDown;    // wrapping around bottom

                    // weight x distance worse than y distance
                    int dist = 2 * Math.Abs(info.X - currentPos.X) + ydist;
                    if (dist < min)
                    {
                        min = dist;
                        id = i;
                    }
                }
            }
            else if (e.Input == GameInput.Right)
            {
                for (var i = 0; i < options.Count; i++)
                {
                    if (i == selectedId) continue;

                    var info = options[i];
                    int xdist = info.X - currentPos.X;
                    if (xdist == 0) continue;

                    if (xdist < 0) xdist += Game.CurrentGame.PixelsAcross;    // wrapping around bottom

                    int dist = 2 * Math.Abs(info.Y - currentPos.Y) + xdist;
                    if (dist < min)
                    {
                        min = dist;
                        id = i;
                    }
                }
            }
            else if (e.Input == GameInput.Left)
            {
                for (var i = 0; i < options.Count; i++)
                {
                    if (i == selectedId) continue;

                    var info = options[i];
                    int xdist = currentPos.X - info.X;
                    if (xdist == 0) continue;

                    if (xdist < 0) xdist += Game.CurrentGame.PixelsAcross;    // wrapping around bottom

                    int dist = 2 * Math.Abs(info.Y - currentPos.Y) + xdist;
                    if (dist < min)
                    {
                        min = dist;
                        id = i;
                    }
                }
            }

            if (id != selectedId)
            {
                SelectOption(id);
            }
        }