private void CreateEnemySet(int numEnemy)
 {
     for (int i = 0; i < numEnemy; i++)
     {
         PatrolEnemy enemy = new PatrolEnemy();
         mTheSet.Add(enemy);
     }
 }
Example #2
0
 public PatrolEnemySet()
 {
     // Create many ...
     for (int i = 0; i < kNumEnemies; i++)
     {
         PatrolEnemy e = SpawnRandomPatrolEnemy();
         mTheSet.Add(e);
     }
 }
Example #3
0
        public int UpdateSet(Hero hero)
        {
            int     count = 0;
            Vector2 touchPos;

            //Add an enemy at 100m and every 50 after
            //Should an additional enemy be added?
            if (hero.PositionX / 20 > mAddEnemyDistance)
            {
                PatrolEnemy e = SpawnRandomPatrolEnemy();
                mTheSet.Add(e);
                mAddEnemyDistance += 50;
            }

            // destroy and respawn, update and collide with bubbles
            for (int i = mTheSet.Count - 1; i >= 0; i--)
            {
                if (mTheSet[i].DestoryFlag)
                {
                    mTheSet.Remove(mTheSet[i]);
                    mTheSet.Add(SpawnRandomPatrolEnemy());
                    continue;
                }

                if (mTheSet[i].UpdatePatrol(hero, out touchPos))
                {
                    sCollisionEffect.AddEmitterAt(CreateRedParticle, touchPos);
                    count++;
                }

                List <BubbleShot> allBubbleShots = hero.AllBubbleShots();
                int numBubbleShots = allBubbleShots.Count;
                for (int j = numBubbleShots - 1; j >= 0; j--)
                {
                    if (allBubbleShots[j].PixelTouches(mTheSet[i], out touchPos))
                    {
                        mTheSet[i].SetToStuntState();
                        allBubbleShots.RemoveAt(j);
                        sCollisionEffect.AddEmitterAt(CreateRedParticle, touchPos);
                    }
                }
            }

            sCollisionEffect.UpdateParticles();
            RespawnEnemies();
            return(count);
        }
Example #4
0
        public PatrolEnemy SpawnRandomPatrolEnemy()
        {
            int         randNum = (int)(Game1.sRan.NextDouble() * 3);
            PatrolEnemy enemy   = null;

            switch (randNum)
            {
            case (int)EnemyType.BlowFish:
                enemy = new BlowFish();
                break;

            case (int)EnemyType.JellyFish:
                enemy = new JellyFish();
                break;

            case (int)EnemyType.FightingFish:
                enemy = new FightingFish();
                break;

            default:
                break;
            }
            return(enemy);
        }
Example #5
0
 public GameState()
 {
     mEnemy = new PatrolEnemy();
     mHero  = new PlayerControlHero(new Vector2(5, 5));
 }