Esempio n. 1
0
    public async virtual ValueTask Update(CanvasTimingInformation timing)
    {
        if (Visible)
        {
            _showTimer.Run(timing);

            if (Vector2s.AreNear(_pacman.Position, Position, 4))
            {
                await _mediator.Publish(new FruitEatenEvent(this));

                Visible = false;
            }

            return;
        }

        if (_playerStats == null)
        {
            throw new InvalidOperationException("no player stats set!");
        }

        var levelStats = _playerStats.LevelStats;

        if (levelStats.FruitSession.ShouldShow && !_isDemo)
        {
            Visible = true;

            _showTimer.Reset();
        }

        SetFruitItem(levelStats.GetLevelProps().Fruit1);
    }
Esempio n. 2
0
    public async ValueTask Update(CanvasTimingInformation timing)
    {
        _colorTweener.Update(timing);

        var col = (int)(_colorTweener.Position * 255);

        _color = Color.FromArgb(255, col, col, col);

        _tweener?.Update(timing);

        _timer.Run(timing);

        if (_state == State.Idle)
        {
            await idle();
        }

        if (_state == State.ScrollingIn)
        {
            await scrollingIn();
        }

        if (_state == State.Stationary)
        {
            await stationary();
        }

        if (_state == State.ScrollingOut)
        {
            await scrollingOut();
        }
    }
Esempio n. 3
0
        public async ValueTask <ActUpdateResult> Update(CanvasTimingInformation timing)
        {
            if (_finished)
            {
                return(ActUpdateResult.Finished);
            }

            _tempTimers.Update(timing);

            if (_ghostsChasing)
            {
                await _powerPillLegend.Update(timing);

                await _powerPillToEat.Update(timing);

                _ghostTimer.Run(timing);
                _pacTimer.Run(timing);
                _ghostEatenTimer.Run(timing);
            }

            await _pillLegend.Update(timing);

            _tempSprites.Update(timing);

            lerpPacMan();

            foreach (var g in _ghosts)
            {
                if (!g.Alive)
                {
                    continue;
                }

                lerpGhost(g);

                await g.Update(timing);

                if (Vector2s.AreNear(_pacMan.Position, g.Position, 2))
                {
                    ghostEaten(g);

                    if (g.NickName == GhostNickname.Clyde)
                    {
                        _tempTimers.Add(new EggTimer(1.Seconds(), () =>
                        {
                            _finished = true;
                        }));
                    }
                }
            }

            await _pacMan.Update(timing);

            return(ActUpdateResult.Running);
        }
Esempio n. 4
0
    public async ValueTask <ActUpdateResult> Update(CanvasTimingInformation gameContext)
    {
        _ghostTimer.Run(gameContext);
        _pacTimer.Run(gameContext);
        await _worm.Update(gameContext);

        lerpBlinky();
        lerpPacMan();

        await _pacMan.Update(gameContext);

        await _blinky.Update(gameContext);

        await _worm.Update(gameContext);

        return(_finished ? ActUpdateResult.Finished : ActUpdateResult.Running);
    }
Esempio n. 5
0
        public async ValueTask <ActUpdateResult> Update(CanvasTimingInformation timing)
        {
            _blinkyTimer.Run(timing);
            _pacTimer.Run(timing);
            await _bigPacMan.Update(timing);

            lerpBlinky();
            lerpPacMan();

            await _pacMan.Update(timing);

            await _blinky.Update(timing);

            await _bigPacMan.Update(timing);

            return(_finished ? ActUpdateResult.Finished : ActUpdateResult.Running);
        }
Esempio n. 6
0
        public async ValueTask <ActUpdateResult> Update(CanvasTimingInformation timing)
        {
            _blinkyTimer.Run(timing);
            _pacTimer.Run(timing);
            _tearTimer.Run(timing);
            _lookTimer.Run(timing);

            if (_stage == Stage.MovingBlinky)
            {
                lerpBlinky();
            }

            lerpPacMan();

            await _pacMan.Update(timing);

            await _blinky.Update(timing);

            await _lookingBlinky.Update(timing);

            await _snagSprite.Update(timing);

            return(_finished ? ActUpdateResult.Finished : ActUpdateResult.Running);
        }