Пример #1
0
        public void isPokeballCollapsed()
        {
            Pokeball thisPokeball = Pokeballs[pokeballToUse];

            if (thisPokeball.isCollapsed())
            {
                pokeballToUse++;
                remainedPokeball--;
                resetTurn();
            }
        }
Пример #2
0
        public void LoadContent(ContentManager Content, String imag, String walkImag,
                                String throwImag, String loseImag, int rows, int columns)
        {
            Rows         = rows;
            Columns      = columns;
            currentFrame = 0;
            totalFrames  = Rows * Columns;
            texture      = Content.Load <Texture2D>(imag);
            walkTexture  = Content.Load <Texture2D>(walkImag);
            throwTexture = Content.Load <Texture2D>(throwImag);
            loseTexture  = Content.Load <Texture2D>(loseImag);


            arrow          = Content.Load <Texture2D>("arrow");
            arrowRectangle = new Rectangle(0, 0, arrow.Width, arrow.Height);
            arrowOrigin    = new Vector2((arrowPosition.X + arrowRectangle.Width) / 2,
                                         (arrowPosition.Y + arrowRectangle.Height) / 2);

            origin = new Vector2(0, 0);

            powerRectangle            = new PowerRectangle(graphicsDevice, spriteBatch);
            powerRectangle.position.X = 100;
            powerRectangle.position.Y = 100;
            powerRectangle.LoadContent();
            pokeball1 = new Pokeball(graphicsDevice, spriteBatch);
            pokeball2 = new Pokeball(graphicsDevice, spriteBatch);
            pokeball3 = new Pokeball(graphicsDevice, spriteBatch);
            pokeball1.LoadContent(Content, "pokeball/pokeball1");
            pokeball2.LoadContent(Content, "pokeball/pokeball2");
            pokeball3.LoadContent(Content, "pokeball/pokeball3");
            Pokeballs.Add(pokeball1);
            Pokeballs.Add(pokeball2);
            Pokeballs.Add(pokeball3);

//            item1 = new Item(graphicsDevice, spriteBatch);
//            item2 = new Item(graphicsDevice, spriteBatch);
//            item3 = new Item(graphicsDevice, spriteBatch);
//            item1.LoadContent(Content, "item/change_wind", 100, 1000);
//            item2.LoadContent(Content, "item/freeze", 210, 1000);
//            item3.LoadContent(Content, "item/double_size", 320, 1000);
//
//            Items.AddLast(item1);
//            Items.AddLast(item2);
//            Items.AddLast(item3);

            remainedPokeball = Pokeballs.Count();
        }
Пример #3
0
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            lastKeyboardState = keyboardState;
            keyboardState     = Keyboard.GetState();

            millisec++;
            if (millisec % 60 == 0)
            {
                millisec = 0;
                sec++;
            }

            if (turnTimeLimit - sec == 0)
            {
                timesUp = true;
                sec     = 0;
                swapPlayer();
            }

            if (player1.remainedPokeball == 0 && player2.remainedPokeball == 0)
            {
                if (player1.allCP > player2.allCP)
                {
                    player2.lose = true;
                }
                else
                {
                    player1.lose = true;
                }
            }

            foreach (var player in Players)
            {
//                if (player_role == player.Key)
                Player thisPlayer = player.Value;
                if (thisPlayer.positionY + thisPlayer.destinationRectangle.Height < ground1.position.Y)
                {
                    thisPlayer.positionY  += thisPlayer.accerelate;
                    thisPlayer.accerelate += PokeBoomzGame.gravity;
                }
                else
                {
                    thisPlayer.positionY  = ground1.position.Y - thisPlayer.destinationRectangle.Height;
                    thisPlayer.accerelate = 0;
                }
                if (thisPlayer.myTurn && thisPlayer.remainedPokeball == 0)
                {
                    swapPlayer();
                }
                player.Value.Update();

                foreach (var pokemon in Pokemons)
                {
                    if (thisPlayer.remainedPokeball > 0 && thisPlayer.isThrown)
                    {
                        Pokeball thisPokeball = thisPlayer.Pokeballs[thisPlayer.pokeballToUse];
                        if (thisPokeball.initialized && thisPokeball.isThrown)
                        {
                            Vector2 lPokeball = new Vector2(thisPokeball.positionCenter.X,
                                                            thisPokeball.positionCenter.Y);
                            if (lPokeball.X >= pokemon.left && lPokeball.X <= pokemon.right &&
                                lPokeball.Y >= pokemon.top && lPokeball.Y <= pokemon.btm)
                            {
                                thisPokeball.hitPokemon = true;
                                pokemon.isHit           = true;
                                hittedPokemon           = pokemon;
                                thisPlayer.allCP       += pokemon.cp;
                            }
                        }
                    }
                }
            }

            Pokemons.Remove(hittedPokemon);

            foreach (var pokemon in Pokemons)
            {
                if (pokemon.type == "fly")
                {
                    if (pokemon.positionY + pokemon.destinationRectangle.Height > ground1.position.Y)
                    {
                        pokemon.positionY = ground1.position.Y - pokemon.destinationRectangle.Height;
                    }
                }
                else
                {
                    if (pokemon.positionY + pokemon.destinationRectangle.Height < ground1.position.Y)
                    {
                        pokemon.positionY  += pokemon.accerelate;
                        pokemon.accerelate += PokeBoomzGame.gravity;
                    }
                    else
                    {
                        pokemon.positionY  = ground1.position.Y - pokemon.destinationRectangle.Height;
                        pokemon.accerelate = 0;
                    }
                }
                pokemon.Update();
            }
            if (Pokemons.Count() == 0)
            {
                Exit();
            }
            base.Update(gameTime);
        }