private void RandomizeNextWave()
    {
        int totalGeneratedWeight = 0;
        int curEnemyWeight       = 0;

        for (int i = 0; i < enemies.Count; i++)
        {
            EnemyDescriptor enemyDescriptor = enemies [i];

            if (totalGeneratedWeight == totalEnemyWeight)
            {
                //Debug.Log ("Max Weight reached, setting remaining weights to 0");
                for (int j = i; j < enemies.Count; j++)
                {
                    enemyDescriptor = enemies [i];
                    enemyDescriptor.SetCurWeight(0);
                }
                break;
            }
            else if (i == enemies.Count - 1)
            {
                curEnemyWeight = totalEnemyWeight - totalGeneratedWeight;
                enemyDescriptor.SetCurWeight(curEnemyWeight);
                break;
            }

            curEnemyWeight        = Mathf.Clamp(Random.Range(enemyDescriptor.minWeight, enemyDescriptor.maxWeight + 1), enemyDescriptor.minWeight, totalEnemyWeight - totalGeneratedWeight);
            totalGeneratedWeight += curEnemyWeight;
            //Debug.Log ("Current generated weight:" + curEnemyWeight + " Total generated weight:" + totalGeneratedWeight);
            enemyDescriptor.SetCurWeight(curEnemyWeight);
        }

        CalculateEnemyWeights();
    }
Ejemplo n.º 2
0
        private IEnemy CreateSpawnEnemy()
        {
            IEnemy          spawnEnemy    = new Goomba(this.CurrentPosition, true);
            EnemyDescriptor randomPowerup = (EnemyDescriptor)this.RandomNumber.Next(0, EnemySpawnerConfig.NumberOfUniqueEnemies);
            bool            rightFacing   = this.RandomNumber.Next(0, 2) == 1;

            switch (randomPowerup)
            {
            case EnemyDescriptor.Goomba:
                spawnEnemy = new Goomba(this.CurrentPosition, rightFacing);
                break;

            case EnemyDescriptor.Koopa:
                spawnEnemy = new Koopa(this.CurrentPosition, rightFacing);
                break;
            }
            return(spawnEnemy);
        }
Ejemplo n.º 3
0
        public void AddEnemy(EnemyDescriptor e)
        {
            e.StartingTime = TimeElapsed;

            EnemiesToCreate.Add(e);
            EnemiesCount++;
        }