Beispiel #1
0
        public void HandleEvent(Event e)
        {
            if (e.Args.Key == Keys.F1)
            {
                debug = !debug;
            }
            else if (e.Args.Key == Keys.Enter && pauseSound.State == SoundState.Stopped)
            {
                Paused = !Paused;

                if (Paused)
                {
                    LevelManager.Music.Pause();
                }

                pauseSound.Play();
            }
        }
Beispiel #2
0
        public void HandleEvent(Event e)
        {
            if (e.Type != KeyboardEvent.KEY_PRESSED)
            {
                return;
            }

            if (e.Args.Key == konami[konamiIndex])
            {
                konamiIndex++;
                if (konamiIndex == konami.Length)
                {
                    if (!Player.Plint)
                    {
                        success.Play();
                        Player.Plint = true;
                    }

                    konamiIndex = 0;
                }
            }
            else
            {
                konamiIndex = 0;

                if (e.Args.Key == Keys.RightShift)
                {
                    index = (++index) % 2;
                }
                else if (e.Args.Key == Keys.Enter)
                {
                    if (index == 0)
                    {
                        StateManager.Push(new StageIntro());
                    }
                    else
                    {
                        // TODO: continue
                    }
                }
            }
        }
Beispiel #3
0
        public void HandleEvent(Event e)
        {
            switch (e.Type) {
                case KeyboardEvent.KEY_PRESSED:
                    if (e.Args.Key == Keys.Up || e.Args.Key == Keys.Down || e.Args.Key == Keys.Left || e.Args.Key == Keys.Right)
                    {
                        if (!keys.Contains(e.Args.Key))
                        {
                            keys.Add(e.Args.Key);
                        }
                    }
                    else if (e.Args.Key == Keys.Z && !Stage.Paused && !LevelManager.CurrentLevel.GetTileAt(new Vector2(AABB.Center.X, AABB.Center.Y)).Solid)
                    {
                        LevelManager.CurrentLevel.AddBomb(LevelManager.CurrentLevel.GetTileAt(new Vector2(AABB.Center.X, AABB.Center.Y)).TileX, LevelManager.CurrentLevel.GetTileAt(new Vector2(AABB.Center.X, AABB.Center.Y)).TileY);
                        LevelManager.CurrentLevel.GetTileAt(new Vector2(AABB.Center.X, AABB.Center.Y)).Solid = true;
                    }
                    break;

                case KeyboardEvent.KEY_RELEASED:
                    keys.Remove(e.Args.Key);
                    break;

            }
        }
Beispiel #4
0
        public void HandleEvent(Event e)
        {
            // BOMB_DETONATED should be the only event type
            if (e.Type == GameEvent.BOMB_DETONATED)
            {
                var bomb = e.Source as Bomb;
                bombs.Remove(bomb);

                explosions.Add(new Explosion(ExplosionPart.CENTER)
                {
                    Position = new Vector2(bomb.Position.X, bomb.Position.Y)
                });

                bool up = true, down = true, left = true, right = true;
                for (var i = 1; i <= Blackboard.BombRadius; i++)
                {
                    if (i == Blackboard.BombRadius)
                    {
                        if (left && bomb.TileX - i >= 0 && !tiles[bomb.TileY, bomb.TileX - i].Solid)
                        {
                            explosions.Add(new Explosion(ExplosionPart.LEFT)
                            {
                                Position = new Vector2(bomb.Position.X - (64 * i), bomb.Position.Y)
                            });
                        }
                        else
                        {
                            left = false;
                        }

                        if (right && bomb.TileX + i <= 30 && !tiles[bomb.TileY, bomb.TileX + i].Solid)
                        {
                            explosions.Add(new Explosion(ExplosionPart.RIGHT)
                            {
                                Position = new Vector2(bomb.Position.X + (64 * i), bomb.Position.Y)
                            });
                        }
                        else
                        {
                            right = false;
                        }

                        if (up && bomb.TileY - i >= 0 && !tiles[bomb.TileY - i, bomb.TileX].Solid)
                        {
                            explosions.Add(new Explosion(ExplosionPart.TOP)
                            {
                                Position = new Vector2(bomb.Position.X, bomb.Position.Y - (64 * i))
                            });
                        }
                        else
                        {
                            up = false;
                        }

                        if (down && bomb.TileY + i <= 12 && !tiles[bomb.TileY + i, bomb.TileX].Solid)
                        {
                            explosions.Add(new Explosion(ExplosionPart.BOTTOM)
                            {
                                Position = new Vector2(bomb.Position.X, bomb.Position.Y + (64 * i))
                            });
                        }
                        else
                        {
                            down = false;
                        }
                    }
                    else
                    {
                        if (left && bomb.TileX - i >= 0 && !tiles[bomb.TileY, bomb.TileX - i].Solid)
                        {
                            explosions.Add(new Explosion(ExplosionPart.HORIZONTAL)
                            {
                                Position = new Vector2(bomb.Position.X - (64 * i), bomb.Position.Y)
                            });
                        }
                        else
                        {
                            left = false;
                        }

                        if (right && bomb.TileX + i <= 30 && !tiles[bomb.TileY, bomb.TileX + i].Solid)
                        {
                            explosions.Add(new Explosion(ExplosionPart.HORIZONTAL)
                            {
                                Position = new Vector2(bomb.Position.X + (64 * i), bomb.Position.Y)
                            });
                        }
                        else
                        {
                            right = false;
                        }

                        if (up && bomb.TileY - i >= 0 && !tiles[bomb.TileY - i, bomb.TileX].Solid)
                        {
                            explosions.Add(new Explosion(ExplosionPart.VERTICAL)
                            {
                                Position = new Vector2(bomb.Position.X, bomb.Position.Y - (64 * i))
                            });
                        }
                        else
                        {
                            up = false;
                        }

                        if (down && bomb.TileY + i <= 12 && !tiles[bomb.TileY + i, bomb.TileX].Solid)
                        {
                            explosions.Add(new Explosion(ExplosionPart.VERTICAL)
                            {
                                Position = new Vector2(bomb.Position.X, bomb.Position.Y + (64 * i))
                            });
                        }
                        else
                        {
                            down = false;
                        }
                    }
                }
            }
        }