Ejemplo n.º 1
0
        private void UpdateEnemies()
        {
            //destructibleObjects.UpdateAll(gameSpeed);
            for (int i = 0; i < EnemyShips.Count; i++)
            {
                EnemyShip curEnemy = EnemyShips.Dequeue();
                curEnemy.Update(delta);
                curEnemy.fire(Bullets, bulletTextures, r);

                bool myShipIsHit = curEnemy.Intersects(Ship.Bounds); // Should this be here??
                if (myShipIsHit)
                {
                    Ship.Health -= 10 * ((int)(curEnemy.CurSpeed.Y) / 4); // Customize depending on stuff? (type of ship?)
                    if (Ship.Health <= 0)
                    {
                        gameOver = true;
                    }
                }

                bool onScreen = !(curEnemy.Position.Y > MaxY) && !myShipIsHit;
                if (onScreen) // If the Enemy is not past the bottom of the screen
                {
                    EnemyShips.Enqueue(curEnemy);
                }
            }
        }
Ejemplo n.º 2
0
        /*
         * public delegate somethingSomethingSomething??
         *
         * public void PrototypicalRedundanyReducer(theDelegate method, queueToProces objects)
         * {
         *  int size = objects.Count;
         *  for (int i = 0; i < size; i++)
         *  {
         *      theDelegate(objects);
         *  }
         * }
         *
         * public methodForDelegateStuff1(queueToProcess????)
         * {
         *
         * }
         *
         * public methodForDelegateStuff2(queueToProcess????)
         * {
         *
         * }
         */

        private bool TryHit(BulletObject curBullet)
        {
            bullet1.Center = (new Vector3(curBullet.Position, 0f));

            if (!curBullet.isFriendly() && bullet1.Intersects(Ship.Bounds))
            {
                Ship.Health -= 10; // DO STUFF
                return(true);
            }
            else if (curBullet.isFriendly())
            {
                int destSize = EnemyShips.Count;
                // Go through destructables, check if each one is hit
                for (int i = 0; i < destSize; i++)
                {
                    EnemyShip curDest = EnemyShips.Dequeue();
                    if (curDest.Intersects(bullet1))
                    {
                        // Maybe spawn some debris here, because somethings been hit?
                        curDest.Damage(curBullet);
                        if (!curDest.IsDead())
                        {
                            EnemyShips.Enqueue(curDest);
                        }
                        else
                        {
                            score += 100;
                            // something's been killed, do stuff!
                            trySpawnRewards(curDest.Position);
                        }
                        return(true);
                    }
                    else
                    {
                        EnemyShips.Enqueue(curDest);
                    }
                }
            }
            return(false);
        }