コード例 #1
0
ファイル: Jogo.cs プロジェクト: osm10/Xadrez
        public void InicializarJogo()
        {
            while (_estadoJogo != EstadoJogo.FimJogo)
            {
                switch (_estadoJogo)
                {
                case EstadoJogo.InscreverJogadores:
                    Console.WriteLine("Jogador {0} introduza o seu nome", _tabuleiroController.JogadoresInscritos() + 1);
                    string nome = Console.ReadLine();
                    _tabuleiroController.InscreverJogador(nome);
                    if (_tabuleiroController.JogadoresInscritos() == 2)
                    {
                        _estadoJogo = EstadoJogo.Jogar;
                    }
                    break;

                case EstadoJogo.Jogar:

                    break;

                case EstadoJogo.FimJogo:
                    break;
                }
            }
        }
コード例 #2
0
ファイル: Jogo.cs プロジェクト: osm10/Xadrez
 public Jogo()
 {
     _tabuleiroController = new TabuleiroController();
     _estadoJogo          = EstadoJogo.InscreverJogadores;
     Console.WriteLine("Bem vindo ao jogo de xadrez");
     Console.WriteLine("Iremos processar a inscrição dos jogadores");
 }
コード例 #3
0
ファイル: Game1.cs プロジェクト: fabiovianactu/TCC
        protected override void LoadContent()
        {
            spriteBatch    = new SpriteBatch(GraphicsDevice);
            EstadoCorrente = EstadoJogo.Inicio;

            // Carrega Cenario
            new Cenario();
            Cenario.CarregaCenario(this.Content);

            // Carrega Personagem
            new Pontuacao();
            Pontuacao.CarregaPontuacao(this.Content);

            // Carrega plataformas
            new Plataformas();
            Plataformas.CarregaPlataforma(this.Content);

            // Carrega Personagem
            new Personagem();
            Personagem.CarregaPersonagem(this.Content);
        }
コード例 #4
0
        public void InicializarJogo()
        {
            while (_estadoJogo != EstadoJogo.FimJogo)
            {
                switch (_estadoJogo)
                {
                case EstadoJogo.InscreverJogadores:
                    Console.WriteLine("Jogador {0} introduza o seu nome", _tabuleiroController.JogadoresInscritos() + 1);
                    string nome = Console.ReadLine();
                    _tabuleiroController.InscreverJogador(nome);
                    if (_tabuleiroController.JogadoresInscritos() == 2)
                    {
                        _estadoJogo = EstadoJogo.Jogar;
                        _tabuleiroController.GetListaJogadores().FirstOrDefault().TurnoJogar = true;
                    }
                    break;

                case EstadoJogo.Jogar:
                    Console.WriteLine("É a vez do jogador {0} jogar\n",
                                      _tabuleiroController.GetListaJogadores().FirstOrDefault(j => j.TurnoJogar = true).Nome);
                    Console.Write("Indique a linha onde quer jogar (a - h) ");
                    ConsoleKeyInfo consoleKeyInfoLine = Console.ReadKey();
                    // todo: validar linha
                    Console.Write("Indique a coluna onde quer jogar (0 - 7) ");
                    ConsoleKeyInfo consoleKeyInfoColumn = Console.ReadKey();
                    // todo: validar coluna
                    // todo: validar possíveis posições das peças
                    // todo: validar possíveis movimentos dos jogadores
                    _tabuleiroController.TrocarTurno();
                    break;

                case EstadoJogo.FimJogo:
                    break;
                }
            }
        }
コード例 #5
0
        private void ValidarSeMadeiraBateNaBola()
        {
            bool emcontato = false;
            for (int i = 0; i < _madeiras.Count; i++)
            {
                if (BolaEmContatoComMadeira(_madeiras[i]))
                {

                    //BitmapImage bmp = new BitmapImage(new Uri("/FallingBall;component/Images/madeira_red.png", UriKind.Relative));
                    //Image image = new Image();
                    //_madeiras[i].RefImage.Source = bmp;
                    emcontato = true;
                    _madeiraEmContato = _madeiras[i];
                }
            }

            if (emcontato)
            {
                this._estadoBola = EstadoBola.NaMadeira;
                if (this._madeiraEmContato.EhDoMal)
                {
                    _estadoJogo = EstadoJogo.Fim;
                    this.ball.FimAnimacaoEndGameBola += new Action(ball_FimAnimacaoEndGameBola);
                    this.ball.Destroy();
                }
            }
            else
            {
                this._estadoBola = EstadoBola.Descendo;
                _madeiraEmContato = null;
            }
        }
コード例 #6
0
 private void btnPause_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     if (_estadoJogo == EstadoJogo.Andamento)
     {
         ((Button)sender).Content = "Play";
         this._estadoJogo = EstadoJogo.Pause;
     }
     else if (_estadoJogo == EstadoJogo.Pause)
     {
         ((Button)sender).Content = "Pause";
         this._estadoJogo = EstadoJogo.Andamento;
     }
 }
コード例 #7
0
 private void ValidarSeGameOver()
 {
     if (ballPosition.Y + ball.Height <= 0
         || ballPosition.Y > (800 - 44))
     {
         _estadoJogo = EstadoJogo.Fim;
         this.DirecionarParaGameOver();
     }
 }
コード例 #8
0
ファイル: Game1.cs プロジェクト: merovigiam/estudo_xna
 private void updatePontuacao()
 {
     if (currentKeyboardState.IsKeyDown(Keys.Space))
         this.estado = EstadoJogo.Menu;
 }
コード例 #9
0
ファイル: Game1.cs プロジェクト: merovigiam/estudo_xna
        private void UpdatePlayer(GameTime gameTime)
        {
            player.Update(gameTime);

            // Windows Phone Controls
            //while (TouchPanel.IsGestureAvailable)
            //{
            //    GestureSample gesture = TouchPanel.ReadGesture();
            //    if (gesture.GestureType == GestureType.FreeDrag)
            //    {
            //        player.Position += gesture.Delta;
            //    }
            //}

            //// Get Thumbstick Controls
            //player.Position.X += currentGamePadState.ThumbSticks.Left.X * playerMoveSpeed;
            //player.Position.Y -= currentGamePadState.ThumbSticks.Left.Y * playerMoveSpeed;

            // Use the Keyboard / Dpad
            if (currentKeyboardState.IsKeyDown(Keys.Left) ||  currentGamePadState.DPad.Left == ButtonState.Pressed)
            {
                player.Position.X -= playerMoveSpeed;
            }
            if (currentKeyboardState.IsKeyDown(Keys.Right) || currentGamePadState.DPad.Right == ButtonState.Pressed)
            {
                player.Position.X += playerMoveSpeed;
            }
            if (currentKeyboardState.IsKeyDown(Keys.Up) || currentGamePadState.DPad.Up == ButtonState.Pressed)
            {
                player.Position.Y -= playerMoveSpeed;
            }
            if (currentKeyboardState.IsKeyDown(Keys.Down) || currentGamePadState.DPad.Down == ButtonState.Pressed)
            {
                player.Position.Y += playerMoveSpeed;
            }

            // Make sure that the player does not go out of bounds
            player.Position.X = MathHelper.Clamp(player.Position.X, 0, GraphicsDevice.Viewport.Width - player.Width);
            player.Position.Y = MathHelper.Clamp(player.Position.Y, 0, GraphicsDevice.Viewport.Height - player.Height);

            if (nivelTiro == 1 && score > 1000)
                nivelTiro++;
            if (nivelTiro == 2 && score > 2000)
                nivelTiro++;

            // Fire only every interval we set as the fireTime
            if (gameTime.TotalGameTime - previousFireTime > fireTime)
            {
                // Reset our current time
                previousFireTime = gameTime.TotalGameTime;

                // Add the projectile, but add it to the front and center of the player
                // Play the laser sound
                laserSound.Play();
                AddProjectile(player.Position);
            }
            // reset score if player health goes to zero
            if (player.Health <= 0)
            {
                estado = EstadoJogo.Pontuacao;
                limparObjetosTela();
                nivelTiro = 1;
                player.Health = 100;
            }
        }
コード例 #10
0
ファイル: Game1.cs プロジェクト: merovigiam/estudo_xna
        private void updateMenuPrincipal()
        {
            if (currentKeyboardState.IsKeyDown(Keys.Down) || currentGamePadState.DPad.Up == ButtonState.Pressed)
            {
                if (this.posicaoCursor == 0)
                    posicaoCursor++;
            }
            if (currentKeyboardState.IsKeyDown(Keys.Up) || currentGamePadState.DPad.Down == ButtonState.Pressed)
            {
                if (this.posicaoCursor == 1)
                    posicaoCursor--;
            }

            if (currentKeyboardState.IsKeyDown(Keys.Enter))
            {
                score = 0;
                if (posicaoCursor == 0)
                    estado = EstadoJogo.Jogando;
                else
                    estado = EstadoJogo.Parado;
            }

            if (currentKeyboardState.IsKeyDown(Keys.Escape))
                estado = EstadoJogo.Parado;
        }
コード例 #11
0
ファイル: Game1.cs プロジェクト: merovigiam/estudo_xna
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            previousGamePadState = currentGamePadState;
            previousKeyboardState = currentKeyboardState;

            // Read the current state of the keyboard and gamepad and store it
            currentKeyboardState = Keyboard.GetState();
            currentGamePadState = GamePad.GetState(PlayerIndex.One);

            switch(estado) {
                case EstadoJogo.Menu:
                    updateMenuPrincipal();

                    break;

                case EstadoJogo.Jogando:

                    // Allows the game to exit
                    if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                        this.Exit();

                    if (currentKeyboardState.IsKeyDown(Keys.Escape))
                        this.estado = EstadoJogo.Pontuacao;

                    // Save the previous state of the keyboard and game pad so we can determinesingle key/button presses

                    //Update the player
                    UpdatePlayer(gameTime);
                    bgLayer1.Update();
                    bgLayer2.Update();
                    // Update the enemies
                    UpdateEnemies(gameTime);

                    // Update the projectiles
                    UpdateProjectiles();
                    // Update the explosions
                    UpdateExplosions(gameTime);

                    // Update the collision
                    UpdateCollision();

                    base.Update(gameTime);
                    break;

                case EstadoJogo.Parado:
                    this.Exit();
                    break;

                case EstadoJogo.Pontuacao:

                    updatePontuacao();
                    break;
            }
        }
コード例 #12
0
ファイル: Game1.cs プロジェクト: merovigiam/estudo_xna
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            nivelTiro = 1;
            posicaoCursor = 0;
            // TODO: Add your initialization logic here
            player = new Player();
            // Set a constant player move speed
            playerMoveSpeed = 8.0f;

            bgLayer1 = new ParallaxBackground();
            bgLayer2 = new ParallaxBackground();
            // Initialize the enemies list
            enemies = new List<Enemy>();

            // Set the time keepers to zero
            previousSpawnTime = TimeSpan.Zero;

            // Used to determine how fast enemy respawns
            enemySpawnTime = TimeSpan.FromSeconds(1.0f);

            // Initialize our random number generator
            random = new Random();
            //Enable the FreeDrag gesture.
            //TouchPanel.EnabledGestures = GestureType.FreeDrag;

            projectiles = new List<Projectile>();
            explosions = new List<Animation>();
            // Set the laser to fire every quarter second
            fireTime = TimeSpan.FromSeconds(.15f);
            //Set player's score to zero
            score = 0;
            estado = EstadoJogo.Menu;

            base.Initialize();
        }