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
ファイル: Scene.cs プロジェクト: laazer/cs_megaman
 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
ファイル: GameHandler.cs プロジェクト: laazer/cs_megaman
 protected abstract void GameInputReceived(GameInputEventArgs e);
コード例 #5
0
 protected abstract void GameInputReceived(GameInputEventArgs e);
コード例 #6
0
ファイル: Menu.cs プロジェクト: andreinitescu/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);
            }
        }
コード例 #7
0
        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
ファイル: StageHandler.cs プロジェクト: laazer/cs_megaman
 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);
            }
        }