Esempio n. 1
0
        private IncomingDots[] NewWave()
        {
            waveNumber++;

            if (waveSpawnTimer <= 500)
            {
                waveSpawnTimer = 500 - (waveNumber);

                if (waveSpawnTimer <= 300)
                {
                    waveSpawnTimer = 300;
                }
            }
            else
            {
                waveSpawnTimer -= (30 * waveNumber);
            }

            numEnemyDotsToSpawn = (int)(Math.Round
                                            (Math.Sqrt(waveNumber + 1) * 10, 0, MidpointRounding.AwayFromZero));
            IncomingDots[] enemyDotList = new IncomingDots[numEnemyDotsToSpawn];


            enemyDotList = PopulateEnemyDotList(enemyDotList);
            return(enemyDotList);
        }
Esempio n. 2
0
        private IncomingDots[] PopulateEnemyDotList(IncomingDots[] enemyDotList)
        {
            Viewport view = graphics.GraphicsDevice.Viewport;
            Vector2 screenCenter = new Vector2(view.Width/2f, view.Height);

            for (int i = 0; i < numEnemyDotsToSpawn; i++)
            {
                enemyDotList[i].hasBeenPlaced = false;
                enemyDotList[i].isAlive = false;
                enemyDotList[i].velocity = 200+(waveNumber*3);

                #region assign random enemy dot color

                if (waveNumber <= 3)
                    enemyRandom = r.Next(9) + 1;
                else
                    enemyRandom = r.Next(15)+1;

                switch (enemyRandom)
                {
                    case 1:
                    case 2:
                    case 3:
                        enemyDotList[i].color = IncomingDots.possibleColors.red;
                        break;
                    case 4:
                    case 5:
                    case 6:
                        enemyDotList[i].color = IncomingDots.possibleColors.blue;
                        break;
                    case 7:
                    case 8:
                    case 9:
                        enemyDotList[i].color = IncomingDots.possibleColors.yellow;
                        break;
                    case 10:
                    case 11:
                        enemyDotList[i].color = IncomingDots.possibleColors.purple;
                        break;
                    case 12:
                    case 13:
                        enemyDotList[i].color = IncomingDots.possibleColors.orange;
                        break;
                    case 14:
                    case 15:
                        enemyDotList[i].color = IncomingDots.possibleColors.green;
                        break;
                    default:
                        break;
                }
                #endregion

                #region assign random X starting position on top of screen

                enemyDotList[i].spawnCoordX = r.Next(640)+1;

                enemyDotList[i].spawnCoordY = -(view.Height);
                enemyDotList[i].spawnPosition.X = enemyDotList[i].spawnCoordX;
                enemyDotList[i].spawnPosition.Y = enemyDotList[i].spawnCoordY;

                enemyDotList[i].direction = screenCenter - enemyDotList[i].spawnPosition;

                #endregion

            }
            return enemyDotList;
        }
Esempio n. 3
0
        private bool CheckIfListDead(IncomingDots[] enemyDotList)
        {
            bool listDead = true;

            foreach(IncomingDots incomingDot in enemyDotList)
            {
                if (incomingDot.hasBeenPlaced && incomingDot.isAlive)
                    listDead = false;
            }

            return listDead;
        }
Esempio n. 4
0
        private IncomingDots[] NewWave()
        {
            waveNumber++;

            if (waveSpawnTimer <= 500)
            {
                waveSpawnTimer = 500 - (waveNumber);

                if (waveSpawnTimer <= 300)
                    waveSpawnTimer = 300;
            }
            else
                waveSpawnTimer -= (30 * waveNumber);

            numEnemyDotsToSpawn = (int)(Math.Round
                (Math.Sqrt(waveNumber + 1) * 10, 0, MidpointRounding.AwayFromZero));
            IncomingDots[] enemyDotList = new IncomingDots[numEnemyDotsToSpawn];

            enemyDotList = PopulateEnemyDotList(enemyDotList);
            return enemyDotList;
        }
Esempio n. 5
0
        private void CheckCollision(IncomingDots[] enemyDotList, float timeDelta, Vector2 screenCenter)
        {
            for (int i = 0; i < enemyDotList.Length; i++)
            {
                if (enemyDotList[i].hasBeenPlaced && enemyDotList[i].isAlive)
                {
                    enemyDotList[i].Update(timeDelta);
                }

                if (enemyDotList[i].isAlive)
                {
                    if (enemyDotList[i].spawnPosition.Y >= 950)
                    {
                        enemyRandom = r.Next(6) + 1;
                        switch (enemyRandom)
                        {
                            case 1:
                                dotHitSound1.Play();
                                break;
                            case 2:
                                dotHitSound2.Play();
                                break;
                            case 3:
                                dotHitSound3.Play();
                                break;
                            case 4:
                                dotHitSound4.Play();
                                break;
                            case 5:
                                dotHitSound5.Play();
                                break;
                            case 6:
                                dotHitSound6.Play();
                                break;
                        }

                        enemyDotList[i].isAlive = false;

                        if (player.currentColor == Player.Colors.red && (enemyDotList[i].color == IncomingDots.possibleColors.red
                            || enemyDotList[i].color == IncomingDots.possibleColors.orange
                            || enemyDotList[i].color == IncomingDots.possibleColors.purple))
                            enemyDotList[i].isAlive = false;
                        else if (player.currentColor == Player.Colors.blue && (enemyDotList[i].color == IncomingDots.possibleColors.blue
                            || enemyDotList[i].color == IncomingDots.possibleColors.green
                            || enemyDotList[i].color == IncomingDots.possibleColors.purple))
                            enemyDotList[i].isAlive = false;
                        else if (player.currentColor == Player.Colors.yellow && (enemyDotList[i].color == IncomingDots.possibleColors.yellow
                            || enemyDotList[i].color == IncomingDots.possibleColors.orange
                            || enemyDotList[i].color == IncomingDots.possibleColors.green))
                            enemyDotList[i].isAlive = false;
                        else { player.isAlive = false; }
                    }
                }
            }
        }