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

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

                    //_ = _game.FruitEaten();

                    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().Fruit);
        }
Exemplo n.º 2
0
 public bool IsNearCenter(double precision) => Vector2s.AreNear(SpritePos, CenterPos, precision);