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 <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. 3
0
 bool isNearHouseEntrance() => Vector2s.AreNear(Ghost.Position, Maze.PixelHouseEntrancePoint, .75);