Esempio n. 1
0
        public virtual void Init()
        {
            objects = new ArrayList();
            player  = new Ship();
            enemy   = new EnemySpawn();
            lives   = new LivesUI(playerS);

            Enemy.numDescending = 0;
            score      = 0;
            levelCount = 0;
            LivesUI.setLives(3);
        }
Esempio n. 2
0
        public override void Update(GameTime gameTime)
        {
            rect.Y += (direction < 0 ? 8 : 6 + game.levelCount) * direction;
            if (rect.Y <= -20 || rect.Y >= 650)
            {
                Destroy();
            }

            foreach (GameObject obj in game.getObjects())
            {
                if (direction < 0)
                {
                    if (obj.getType() == Type.ENEMY)
                    {
                        Enemy enemy = (Enemy)obj;
                        if (getLaserRect().Intersects(enemy.getEnemyRect()))
                        {
                            enemy.Damage();
                            Destroy();
                            game.score += 100;
                            if (game.score % 7200 == 0)
                            {
                                LivesUI.addLives();
                            }
                        }
                    }
                }
                else if (direction > 0)
                {
                    if (obj.getType() == Type.SHIP)
                    {
                        Ship ship = (Ship)obj;
                        if (getLaserRect().Intersects(ship.getShipRect()))
                        {
                            ship.Hit();
                            Destroy();
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public void Hit()
        {
            LivesUI.subtractLives();

            this.Destroy();
        }