Esempio n. 1
0
        private Rectangle GetDiggerAnimation(EnemyDigger enemy)
        {
            if (enemy == null)
            {
                return(new Rectangle());
            }
            var res = new Rectangle(new Point(27 * 16 + enemy.CurrentFrame * 16, 7 * 16), new Size(16, 16));

            ChangeEnemyAnimation(enemy);
            return(res);
        }
Esempio n. 2
0
        private void SpawnEnemies()
        {
            _chanceToSpawnEnemy += _difficulty;
            var randomX = Randomizer.Random(CurrentLevel.Width);
            var randomY = Randomizer.Random(CurrentLevel.Height);

            if (CurrentLevel[randomX, randomY].EntityEnumType != GameEntitiesEnum.EmptySpace ||
                _chanceToSpawnEnemy < Randomizer.Random(100))
            {
                return;
            }

            var chanceToSpawn = Randomizer.Random(101);

            if (CurrentLevel._chanceToSpawnSmartDevil > chanceToSpawn)
            {
                CurrentLevel[randomX, randomY] =
                    new SmartDevil(randomX, randomY, () => CurrentLevel, () => Player.PositionX,
                                   () => Player.PositionY, SubstractPlayerHp, () => Player, _playSound);
                _chanceToSpawnEnemy = 0;
            }

            else if (CurrentLevel._chanceToSpawnSmartSkeleton > chanceToSpawn)
            {
                CurrentLevel[randomX, randomY] =
                    new SmartSkeleton(randomX, randomY, () => CurrentLevel, () => Player.PositionX,
                                      () => Player.PositionY, SubstractPlayerHp, () => Player, _playSound);
                _chanceToSpawnEnemy = 0;
            }
            else if (CurrentLevel._chanceToSpawnSmartPeaceful > chanceToSpawn)
            {
                CurrentLevel[randomX, randomY] =
                    new SmartPeaceful(randomX, randomY, () => CurrentLevel, () => Player.PositionX,
                                      () => Player.PositionY, SubstractPlayerHp, () => Player, _playSound);
                _chanceToSpawnEnemy = 0;
            }
            else if (CurrentLevel._chanceToSpawnSmartDigger > chanceToSpawn)
            {
                CurrentLevel[randomX, randomY] =
                    new EnemyDigger(randomX, randomY, () => CurrentLevel, () => Player.PositionX,
                                    () => Player.PositionY, SubstractPlayerHp);
                _chanceToSpawnEnemy = 0;
            }
            else
            {
                CurrentLevel[randomX, randomY] =
                    new EnemyWalker(randomX, randomY, () => CurrentLevel, () => Player.PositionX,
                                    () => Player.PositionY, SubstractPlayerHp);
                _chanceToSpawnEnemy = 0;
            }
        }