Пример #1
0
        /// <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()
        {
            //screensize
            graphics.PreferredBackBufferWidth  = 640;
            graphics.PreferredBackBufferHeight = 640;
            graphics.ApplyChanges();

            //tilemap
            landmap.Init(Content);
            overLay.Init(Content);
            collisionMap.Init(Content);

            //input
            handleInput.Init();

            //battle stats
            enemyHealthCalc.Init();
            yourHealthCalc.Init();

            //pokemon locations
            pokemonLocation = GenFunctions.RandomPokemonLocation();
            msGame          = 0;
            loopTimes       = 0;
            turnTimer       = 0;

            //boolean
            attackDamageParticle      = false;
            enemyAttackDamageParticle = false;

            //transition
            transitionStart = 0;
            transitionEnd   = 1;

            //ghost locations
            ghostLocX  = 300;
            ghostLocY  = 350;
            ghostDrawn = 0;
            ghostSize  = 0.0f;
            ghostUp    = false;

            base.Initialize();
        }
Пример #2
0
        /// <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)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            //music
            if (handleInput._musicOn)
            {
                SoundEffect.MasterVolume = 1.0f;
            }
            else
            {
                SoundEffect.MasterVolume = 0.0f;
            }

            //particle attack
            if (turnTimer >= 10)
            {
                attackDamageParticle = false;
                turnTimer            = 0;
            }
            if (enemyTurnTimer >= 10)
            {
                enemyAttackDamageParticle = false;
                enemyTurnTimer            = 0;
            }

            //player animation
            if (handleInput._inGame)
            {
                cycle.Update(gameTime, animUp, handleInput);
                cycle.Update(gameTime, animDown, handleInput);
                cycle.Update(gameTime, animLeft, handleInput);
                cycle.Update(gameTime, animRight, handleInput);
                //camera
                camera.Update(gameTime, cycle._playerPosition);
            }

            //pokemonlocations
            if (handleInput._inGame)
            {
                msGame += (gameTime.ElapsedGameTime.Milliseconds / 10);
            }
            if ((msGame >= pokemonLocation) && (!ghostUp) && (!handleInput._inMenu) || (handleInput._inBattle))
            {
                if (loopTimes == 0)
                {
                    transitionStart = 0;
                    handleInput.initBattleBooleans();
                }
                loopTimes++;

                enemyPrevHealth  = enemyHealthCalc.ReturnHealth();
                playerPrevHealth = yourHealthCalc.ReturnHealth();
                handleInput.InputInBattle();
                enemyHealthCalc.CalculatePlayerAttack(handleInput);
                enemyHealth = new Sprite(healthBarTexture, new Rectangle(0, 0, enemyHealthCalc.ReturnHealth(), healthBarTexture.Height));

                yourHealthCalc.CalculateEnemyAttack(handleInput);
                yourHealth = new Sprite(healthBarTexture, new Rectangle(0, 0, yourHealthCalc.ReturnHealth(), healthBarTexture.Height));

                if (enemyPrevHealth != enemyHealthCalc.ReturnHealth())
                {
                    attackDamageParticle = true;
                }
                if (playerPrevHealth != yourHealthCalc.ReturnHealth())
                {
                    enemyAttackDamageParticle = true;
                }

                handleInput._APressed = false;
            }

            //resetting the enemy pokemon's health and sprite
            if (yourHealthCalc.ReturnHealth() <= 0 || enemyHealthCalc.ReturnHealth() <= 0)
            {
                //pix mod radius
                if (yourHealthCalc.ReturnHealth() <= 0)
                {
                    if (GrayScaleRadius <= 0)
                    {
                        GrayScaleRadius = 0;
                    }
                    else
                    {
                        GrayScaleRadius -= 25;
                    }
                }
                if (enemyHealthCalc.ReturnHealth() <= 0)
                {
                    if (GrayScaleRadius >= 235)
                    {
                        GrayScaleRadius = 235;
                    }
                    else
                    {
                        GrayScaleRadius += 25;
                    }

                    //ghost
                    ghostUp = true;
                }

                //resetting all health
                enemyHealthCalc.Init();
                yourHealthCalc.Init();
                enemyHealth = new Sprite(healthBarTexture, new Rectangle(0, 0, enemyHealthCalc.ReturnHealth(), healthBarTexture.Height));
                yourHealth  = new Sprite(healthBarTexture, new Rectangle(0, 0, yourHealthCalc.ReturnHealth(), healthBarTexture.Height));
                enemySprite = GenFunctions.returnSprite(slowpoke, pichu, typhlosion, suicune);

                //resetting booleans to the right state
                handleInput.resetBattleBooleans();
                msGame    = 0;
                loopTimes = 0;

                //particle reset
                turnTimer                 = 10;
                attackDamageParticle      = false;
                enemyAttackDamageParticle = false;


                //getting anoth pokemon location
                pokemonLocation = GenFunctions.RandomPokemonLocation();

                //resetting transition time
                transitionStart = 0;
            }

            if (handleInput._inMenu)
            {
                handleInput.HandleInputInMenus();
            }

            //update what the language list is
            textReader.Update(gameTime);

            fpsCounter.Update(gameTime);

            if (handleInput._justQuit)
            {
                Exit();
            }

            //pixmod circle location
            circleCenter.SetValue(new Vector2(159, 159));
            circleRadius.SetValue(GrayScaleRadius);

            //particles
            damage.Initialize(450, 290);
            damage.Update(gameTime);
            enemyDamage.Initialize(180, 550);
            enemyDamage.Update(gameTime);

            //ghost movement
            if (ghostUp)
            {
                ghostLocX += 0;
                ghostLocY -= 2;
                ghostSize += 0.01f;
            }

            //reset to get the ghost going againg
            if ((ghostLocX >= 1200) || (ghostLocY <= -800))
            {
                ghostLocX  = 280;
                ghostLocY  = 320;
                ghostDrawn = 0;
                ghostUp    = false;
                ghostSize  = 0;
            }

            //restart level
            //if((handleInput._isPaused) && (handleInput._inMenu))
            //{
            //}

            base.Update(gameTime);
        }