public static float DistanceBetween(CellIndex cell1, CellIndex cell2) { float a = cell1.X - cell2.X; float b = cell1.Y - cell2.Y; return((float)Math.Sqrt(a * a + b * b)); }
public async ValueTask PillEaten(CellIndex point) { await _ghostHouseDoor.PillEaten(); await IncreaseScoreBy(10); _levelStats.PillEaten(point); }
public static Tile FromIndex(CellIndex index) { var tile = new Tile(); tile.UpdateWithSpritePos(new Vector2(index.X * 8, index.Y * 8)); return(tile); }
public async ValueTask PowerPillEaten(CellIndex point) { FrightSession = new GhostFrightSession(_levelStats.GetLevelProps()); await _ghostHouseDoor.PillEaten(); await IncreaseScoreBy(50); _levelStats.PillEaten(point); }
public void PillEaten(CellIndex cellPosition) { FruitSession.PillEaten(); --PillsRemaining; int index = cellPosition.Y * 29 + cellPosition.X; _currentMap[index] = '+'; }
public void UpdateWithSpritePos(Vector2 spritePos) { SpritePos = spritePos; Index = CellIndex.FromSpritePos(spritePos); TopLeft = new Vector2(Index.X * 8, Index.Y * 8); CenterPos = TopLeft + Vector2s.Four; _isInCenter = CenterPos == spritePos.Round(); handleWrapping(); }
public async ValueTask Update(CanvasTimingInformation timing) { if (_currentPlayerStats == null) { throw new InvalidOperationException("no current player stats"); } if (_lifeStatus == LifeStatus.BeingDigested) { return; } if (_lifeStatus == LifeStatus.Dying || _lifeStatus == LifeStatus.Dead) { handleDying(); return; } updateAnimation(timing); if (_tile.IsNearCenter(2)) { recordInput(timing); recenterInLane(); handleDirection(); } if (_tile.IsNearCenter(1.5)) { await handleWhatIsUnderCell(); var can = _maze.CanContinueInDirection(_direction, _tile); _speed = can ? Constants.PacManBaseSpeed : 0; } float speed = _speed; var levelProps = _currentPlayerStats.LevelStats.GetLevelProps(); var inPillCell = _tile.Index == _pillEatenAt; var pcToUse = inPillCell ? levelProps.PacManDotsSpeedPc : levelProps.PacManSpeedPc; if (_currentPlayerStats.IsInFrightSession) { pcToUse = inPillCell ? levelProps.FrightPacManDotSpeedPc : levelProps.FrightPacManSpeedPc; } if (!inPillCell) { _pillEatenAt = CellIndex.Zero; } speed = speed * (pcToUse / 100); var offset = DirectionToIndexLookup.IndexVectorFor(_direction) * speed; Position = Position + offset; }
public static Vector2 ToVector2(this CellIndex cellIndex) => new Vector2(cellIndex.X, cellIndex.Y);
// special intersections have an extra restriction // ghosts can not choose to turn upwards from these tiles. public static bool IsSpecialIntersection(CellIndex cell) => cell == _specialIntersections[0] || cell == _specialIntersections[1] || cell == _specialIntersections[2] || cell == _specialIntersections[3];
public async ValueTask PowerPillEaten(CellIndex point) { await _playerStats[_currentPlayerIndex].PowerPillEaten(point); updateHighScore(); }
public char GetCellContent(CellIndex point) => _currentMap[getArrayIndex(point)];
static int getArrayIndex(CellIndex point) => point.Y * 29 + point.X;