void Visit(ToxicPotion toxicPotion) { _toxicPotionCount += toxicPotion.Life; }
static GameElement[,] CreateGameElements(int mapSize, int monsterCount, int toxicPotionCount, int healingPotionCount) { Random random = new Random(); int emptyCellCount = mapSize * mapSize - monsterCount - toxicPotionCount - healingPotionCount - 2; GameElement[,] gameElements = new GameElement[mapSize, mapSize]; //Predefined Player and Big Monster gameElements[mapSize - 1, 0] = new EmptyCell(0); gameElements[mapSize - 1, mapSize - 1] = new BigMonster(); while (monsterCount > 0 || toxicPotionCount > 0 || healingPotionCount > 0 || emptyCellCount > 0) { int matrixIndex = random.Next(1, mapSize * mapSize); if (gameElements[(matrixIndex - 1) / mapSize, (matrixIndex - 1) % mapSize] != null) { continue; } if (monsterCount > 0) { gameElements[(matrixIndex - 1) / mapSize, (matrixIndex - 1) % mapSize] = new Monster(); monsterCount--; continue; } if (toxicPotionCount > 0) { gameElements[(matrixIndex - 1) / mapSize, (matrixIndex - 1) % mapSize] = new ToxicPotion(); toxicPotionCount--; continue; } if (healingPotionCount > 0) { gameElements[(matrixIndex - 1) / mapSize, (matrixIndex - 1) % mapSize] = new HealingPotion(); healingPotionCount--; continue; } if (emptyCellCount > 0) { gameElements[(matrixIndex - 1) / mapSize, (matrixIndex - 1) % mapSize] = new EmptyCell(); emptyCellCount--; continue; } } return(gameElements); }