Exemplo n.º 1
0
        public static ValueTask Update(CanvasTimingInformation info, IHumanInterfaceParser input)
        {
            TotalTime = info.TotalTime;

            if (info.TotalTime - _lastTimeKeyboardChecked > .25f.Seconds())
            {
                _lastTimeKeyboardChecked = info.TotalTime;

                if (input.IsKeyCurrentlyDown(Keys.D))
                {
                    ShouldShow = !ShouldShow;
                }
            }

            if (input.WasKeyPressedAndReleased(Keys.A))
            {
                Constants.FramesPerSecond -= 5;
                Constants.FramesPerSecond  = Math.Max(5, Constants.FramesPerSecond);
            }

            if (input.WasKeyPressedAndReleased(Keys.S))
            {
                Constants.FramesPerSecond += 5;
            }

            return(default);
Exemplo n.º 2
0
        public AttractAct(
            ICoinBox coinBox,
            IMediator mediator,
            IHumanInterfaceParser input,
            IGameSoundPlayer gameSoundPlayer)
        {
            MarqueeText[] texts =
            {
                new MarqueeText
                {
                    Text           = "tap or space for 1 player",
                    YPosition      = 195,
                    TimeIdle       = 1.Seconds(),
                    TimeIn         = 2.Seconds(),
                    TimeStationary = 2.Seconds(),
                    TimeOut        = 1.Seconds()
                },
                new MarqueeText
                {
                    Text           = "press or 2 for 2 players",
                    YPosition      = 195,
                    TimeIdle       = 0.Seconds(),
                    TimeIn         = 2.Seconds(),
                    TimeStationary = 2.Seconds(),
                    TimeOut        = 1.Seconds()
                }
            };

            _marquee         = new Marquee(texts);
            _coinBox         = coinBox;
            _mediator        = mediator;
            _input           = input;
            _gameSoundPlayer = gameSoundPlayer;
            _pacmanLogo      =
                new GeneralSprite(new Vector2(192, 25), new Size(36, 152), Vector2.Zero, new Vector2(456, 173));
            _blazorLogo = new BlazorLogo();

            _instructions = new List <Instruction>();

            _startTime = TimeSpan.MinValue;

            _blinky             = new SimpleGhost(GhostNickname.Blinky, Directions.Right);
            _pinky              = new SimpleGhost(GhostNickname.Pinky, Directions.Right);
            _inky               = new SimpleGhost(GhostNickname.Inky, Directions.Right);
            _clyde              = new SimpleGhost(GhostNickname.Clyde, Directions.Right);
            _startTime          = TimeSpan.MinValue;
            _chaseSubActReadyAt = 9.Seconds();

            _chaseSubAct = new ChaseSubAct();
            _lock        = new object();
        }
Exemplo n.º 3
0
 public Game(
     IMediator mediator,
     IFruit fruit,
     IStatusPanel statusPanel,
     IScorePanel scorePanel,
     IGameSoundPlayer gameSoundPlayer,
     IHumanInterfaceParser input,
     IPacMan pacman)
 {
     _mediator        = mediator;
     _fruit           = fruit;
     _statusPanel     = statusPanel;
     _scorePanel      = scorePanel;
     _gameSoundPlayer = gameSoundPlayer;
     _input           = input;
     _pacman          = pacman;
 }
Exemplo n.º 4
0
 public DemoAct(
     IMediator mediator,
     IFruit fruit,
     IMaze maze,
     IPacMan pacman,
     IGhostCollection ghostCollection,
     IHumanInterfaceParser input,
     IGameStats gameStats)
 {
     _mediator        = mediator;
     _fruit           = fruit;
     _maze            = maze;
     _pacman          = pacman;
     _ghostCollection = ghostCollection;
     _input           = input;
     _gameStats       = gameStats;
 }
Exemplo n.º 5
0
 protected Ghost(
     IGameStats gameStats,
     IMediator mediator,
     IHumanInterfaceParser input,
     IPacMan pacman,
     GhostNickname nickName,
     IMaze maze,
     Vector2 startingPoint,
     Direction startingDirection) : base(nickName, startingDirection)
 {
     _gameStats         = gameStats;
     _mediator          = mediator;
     _input             = input;
     _maze              = maze;
     _pacman            = pacman;
     _startingPoint     = startingPoint;
     _startingDirection = startingDirection;
     Tile = new();
 }
Exemplo n.º 6
0
        public PacMan(IMaze maze, IHumanInterfaceParser input, IMediator mediator)
        {
            _maze           = maze;
            _input          = input;
            _mediator       = mediator;
            _demoKeyPresses = new DemoKeyPresses();

            _lifeStatus = LifeStatus.Alive;

            _tile = new Tile();

            _keyPress      = new KeyPressedEvent();
            _framePointers = new Dictionary <Directions, FramePointers>();

            const int left  = 456;
            const int left2 = 472;

            _framePointers[Directions.Up] = new FramePointers(
                new Vector2(left, 32), new Vector2(left2, 32));

            _framePointers[Directions.Down] = new FramePointers(
                new Vector2(left, 48), new Vector2(left2, 48));

            _framePointers[Directions.Left] = new FramePointers(
                new Vector2(left, 16), new Vector2(left2, 16));

            _framePointers[Directions.Right] = new FramePointers(
                new Vector2(left, 0), new Vector2(left2, 0));

            _dyingFrames       = new List <Vector2>();
            _dyingFramePointer = 0;

            for (var i = 0; i < 12; i++)
            {
                _dyingFrames.Add(new Vector2(489 + i * 16, 0));
            }

            _animDirection = new TwoFrameAnimation(65.Milliseconds());

            Reset();
        }
Exemplo n.º 7
0
 public GameAct(
     ICoinBox coinBox,
     IMediator mediator,
     IHumanInterfaceParser input,
     IGameSoundPlayer gameSoundPlayer,
     IGameStats gameStats,
     IGhostCollection ghostCollection,
     IMaze maze,
     IPacMan pacman,
     IFruit fruit)
 {
     _coinBox         = coinBox;
     _mediator        = mediator;
     _input           = input;
     _gameSoundPlayer = gameSoundPlayer;
     _gameStats       = gameStats;
     _ghostCollection = ghostCollection;
     _maze            = maze;
     _pacman          = pacman;
     _fruit           = fruit;
 }
Exemplo n.º 8
0
 public Pinky(IGameStats gameStats, IMediator mediator, IMaze maze, IPacMan pacman, IHumanInterfaceParser input) : base(
         gameStats,
         mediator,
         input,
         pacman,
         GhostNickname.Pinky, maze, Tile.FromCell(15.5f, 11f), GameComponents.Direction.Down)
 {
     _maze       = maze;
     _pacman     = pacman;
     HouseOffset = 0;
 }
Exemplo n.º 9
0
        public Clyde(IGameStats gameStats, IMediator mediator, IMaze maze, IPacMan pacman, IHumanInterfaceParser input) :
            base(
                gameStats,
                mediator,
                input,
                pacman,
                GhostNickname.Clyde, maze, new Vector2(11.5f, 12), GameComponents.Directions.Up)
        {
            _maze   = maze;
            _pacman = pacman;

            HouseOffset = 1;
        }
Exemplo n.º 10
0
 public Blinky(IGameStats gameStats, IMediator mediator, IMaze maze, IPacMan pacman, IHumanInterfaceParser input) : base(
         gameStats,
         mediator,
         input,
         pacman,
         GhostNickname.Blinky,
         maze,
Exemplo n.º 11
0
 public StartButtonAct(IMediator mediator, IHumanInterfaceParser input, ICoinBox coinBox)
 {
     _mediator = mediator;
     _input    = input;
     _coinBox  = coinBox;
 }
Exemplo n.º 12
0
    public AttractAct(
        ICoinBox coinBox,
        IMediator mediator,
        IHumanInterfaceParser input,
        IGameSoundPlayer gameSoundPlayer)
    {
        string version = Assembly
                         .GetEntryAssembly()
                         ?.GetCustomAttribute <AssemblyInformationalVersionAttribute>()
                         ?.InformationalVersion ?? "??";

        MarqueeText[] texts =
        {
            new() {
                Text           = $"v{version}",
                YPosition      = 195,
                TimeIdle       = 1.Seconds(),
                TimeIn         = 1.Seconds(),
                TimeStationary = 1.Seconds(),
                TimeOut        = .5f.Seconds()
            },
            new() {
                Text           = "tap/space - 1 player",
                YPosition      = 195,
                TimeIdle       = 1.Seconds(),
                TimeIn         = 2.Seconds(),
                TimeStationary = 2.Seconds(),
                TimeOut        = 1.Seconds()
            },
            new() {
                Text           = "long press/2 - 2 players",
                YPosition      = 195,
                TimeIdle       = 0.Seconds(),
                TimeIn         = 2.Seconds(),
                TimeStationary = 2.Seconds(),
                TimeOut        = 1.Seconds()
            }
        };

        _marquee         = new(texts);
        _coinBox         = coinBox;
        _mediator        = mediator;
        _input           = input;
        _gameSoundPlayer = gameSoundPlayer;
        _pacmanLogo      =
            new(new(192, 25), new(36, 152), Vector2.Zero, new(456, 173));
        _blazorLogo = new();

        _instructions = new();

        _startTime = TimeSpan.MinValue;

        _blinky             = new(GhostNickname.Blinky, Direction.Right);
        _pinky              = new(GhostNickname.Pinky, Direction.Right);
        _inky               = new(GhostNickname.Inky, Direction.Right);
        _clyde              = new(GhostNickname.Clyde, Direction.Right);
        _startTime          = TimeSpan.MinValue;
        _chaseSubActReadyAt = 9.Seconds();

        _chaseSubAct = new();
        _lock        = new();
    }
Exemplo n.º 13
0
        public Inky(IGameStats gameStats, IMediator mediator, IMaze maze, IPacMan pacman, IHumanInterfaceParser input) :
            base(
                gameStats,
                mediator,
                input,
                pacman,
                GhostNickname.Inky, maze, Tile.FromCell(15.5f, 11), GameComponents.Directions.Up)
        {
            _mediator   = mediator;
            _maze       = maze;
            _pacman     = pacman;
            HouseOffset = -1;

            _getBlinkyRequest = new GetBlinkyRequest();
        }
Exemplo n.º 14
0
 public Blinky(IGameStats gameStats, IMediator mediator, IMaze maze, IPacMan pacman, IHumanInterfaceParser input) :
     base(
         gameStats,
         mediator,
         input,
         pacman,
         GhostNickname.Blinky,
         maze,
         new Vector2(13.5f, 11),
         GameComponents.Directions.Left)
 {
     _pacman        = pacman;
     HouseOffset    = 0;
     _scatterTarget = new ValueTask <CellIndex>(new CellIndex(25, 0));
 }