Exemple #1
0
        public Bandeira(AreaPlayers area, int qualBand)
        {
            //defino o tamanho da bandeira.
            this.tamX = AreaPlayers.CalcPercet(5f, area.GetAltPb);
            this.mostrarInicial = true;
            this.mostrarAtual = this.mostrarInicial;

            //e a bandeira do player local. ----> BANDEIRA DO O LADO EQUERDO.
            if (qualBand == 1)
            {
                this.band = Properties.Resources.Band1;
                band = ResizeImage.ScaleImage(band, tamX, tamX);

                this.xInicial = AreaPlayers.CalcPercet(5, area.GetLargPb) - (this.tamX / 2);
                this.yInicial = area.GetAltPb - (AreaPlayers.CalcPercet(2f, area.GetAltPb) + this.tamX);

                this.xAtual = this.xInicial;
                this.yAtual = this.yInicial;
                this.myBand = false;
                this.bandeira = "B1";
            }//nao e a bandeira do player local. e a bandeira do player remoto.
                //------> BANDEIRA DO LADO DIREITO.
            else if(qualBand == 0)
            {
                this.band = Properties.Resources.Band2;
                band = ResizeImage.ScaleImage(band, tamX, tamX);

                this.xInicial = AreaPlayers.CalcPercet(95, area.GetLargPb) - (this.tamX / 2);
                this.yInicial = AreaPlayers.CalcPercet(12, area.GetAltPb);
                this.xAtual = this.xInicial;
                this.yAtual = this.yInicial;
                this.myBand = true;
                this.bandeira = "B2";
            }
        }
        private void InicializaVariaveis(int qPlayer)
        {
            elementosJogo = new List<ElementoJogo>();   //cria a lista com todos os elementos do jogo.
            this.podeAtirar = true;                     //define que o jogador pode atirar.
            this.areaPlay = new AreaPlayers(this.pb.Size.Width, this.pb.Size.Height);   //cria a rea de jogo do player.
            //refere-se a HUD do jogo.
            this.hud = new Interface(this.pb.Size.Width, this.pb.Size.Height);      //cria a hud do jogo.
            Label[] lab = new Label[] { this.lbl_NomeJog, this.lbl_Placar, this.lbl_TempoRestante, this.lbl_Inativo, this.lbl_FinDeJogo };//pega as labels da hud do jogo que ta no form.
            this.hud.ConfgLabels(lab);  //define as posições e tamanhos das labels que tem no jogo.

            this.qualPlayer = qPlayer;
            this.player = new Player(this.pb.Size.Width, this.pb.Size.Height, this.qualPlayer, this.frm_Inicio);
            playerEnemy = new JogadorInimigo(this.player.tamX, this.player.tamY, this.pb.Size.Width, this.pb.Size.Height, this.qualPlayer);
            elementosJogo.Add(player);

            //thread de desenho.
            this.desenha = new Thread(() => Draw());
            this.desenha.Name = "DesenhaTela";
            this.desenha.Start();

            //timer que controle o tempo de jogo.
            this.tempoRestante = TIMEOUT;
            this.tm_UpdtTempoPartida.Start();

            //cria as bandeiras que ha no jogo.
            this.bands = new Bandeira[2];
            this.bands[0] = new Bandeira(this.areaPlay, 1);
            this.bands[1] = new Bandeira(this.areaPlay, 0);
            this.mB = qPlayer == 1 ? 0 : 1; //dis qual e a minha bandeira.

            //adicionas as bandeiras a lista de lemento de jogo e eo player.
            elementosJogo.Add(bands[0]);
            elementosJogo.Add(bands[1]);

            //cra a lista de tiros.
            this.tiros = new List<Tiro>();
            this.tirosInimigos = new List<Tiro>();

            //cria uma thread que ficara responsavel por verificar se houve alguma colisão do tiro com algum elemento do jogo.
            this.colisaoBala = new Thread(() => ColisaoDaBala());
            this.colisaoBala.Name = "Colicao_Balas";
            this.colisaoBala.Start();

            //cria uma lista onde ficara armazenado os obstaculos. Cria os obstaculos do jogo.
            listaObs = new List<Obstaculo>();
            CriaObstaculos();

            //cria o powerUp do jogo e adiciona a lista de elementos do jogo.
            this.powerUp = new PowerUp(this.pb.Size.Width, this.pb.Size.Height);//cria o powerUp do jogo e adiciona a lista de elementos do jogo.
            elementosJogo.Add(powerUp);

            //atualiza a posição para o outro jogador
            this.player.ForcaEnvioPos();

            //configura o botao que aparece no final da partida para voltar para a tela inicial de jogo.
            ConfiguraBotaoRetornoMenu();

            //carrega a img do chao do campo de batalha e redimensiona para ocupar toda a area dejogo
            this.chao = Properties.Resources.areaJogo;
            this.chao = ResizeImage.ScaleImage(chao, LARGURA, ALTURA);
        }