예제 #1
0
        public void Limpar()
        {
            naves      = new Texture2D[2];
            acabouJogo = false;

            keyboardState = new KeyboardState();
            carregou      = false;
            limpa         = new Limpeza(this.game);
            colisao       = new Colisao(this.game);
            acabouJogo    = false;
            Components.Remove(pShip);
            Components.Remove(sfShip);
        }
예제 #2
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            keyboardState = Keyboard.GetState();

            if (configuranaves.navesSelecionadas != null && !carregou)
            {
                limpa    = new Limpeza(this.game);
                carregou = true;
                int i = 0;
                foreach (TipoNave.Tipo tp in configuranaves.navesSelecionadas)
                {
                    switch (tp)
                    {
                    case TipoNave.Tipo.defenseship:
                        naves[i] = Game.Content.Load <Texture2D>("imagens/defenseship");
                        pShip    = new defenseshipShip(this.game, i + 1);
                        pShip.setBatch(spriteBatch);
                        Components.Add(pShip);
                        break;

                    case TipoNave.Tipo.attackship:
                        naves[i] = Game.Content.Load <Texture2D>("imagens/attackship");
                        sfShip   = new attackshiperShip(this.game, i + 1);
                        sfShip.setBatch(spriteBatch);
                        Components.Add(sfShip);
                        break;
                    }
                    i++;
                }

                // Gerencia os tiros e asteroides
                limpa.gerenciarObstaculos(this.spriteBatch);
            }

            limpa.Update(gameTime);

            // Gerencia o numero de asteroides na tela
            limpa.gerenciarObstaculos(this.spriteBatch);

            colisao.ocorreuColisaoTiroMeteoro();

            foreach (TipoNave.Tipo tp in configuranaves.navesSelecionadas)
            {
                switch (tp)
                {
                case TipoNave.Tipo.defenseship:
                    if (pShip != null)
                    {
                        if (!pShip.isAlive)
                        {
                            acabouJogo = true;
                        }
                    }
                    break;

                case TipoNave.Tipo.attackship:
                    if (sfShip != null)
                    {
                        if (!sfShip.isAlive)
                        {
                            acabouJogo = true;
                        }
                    }
                    break;
                }
            }
        }