public int CalculateEnemyAttack() { int attackNum = GenFunctions.RandomNumber(); if (attackNum == 0) { attackNum = _enemyAttack1; return(attackNum); } if (attackNum == 1) { attackNum = _enemyAttack2; return(attackNum); } if (attackNum == 2) { attackNum = _enemyAttack3; return(attackNum); } else { attackNum = _enemyAttack4; return(attackNum); } }
/// <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(); }
/////////////////////////////////////////////////////handle the input in the game public void HandleInputInGame(Animation anim) { _currentPressed = Keyboard.GetState(); if (Keyboard.GetState().IsKeyDown(Keys.Down)) { anim._IsPlaying = true; _isDown = true; _isLeft = false; _isRight = false; _isUp = false; if (GenFunctions.isMoveable(height + 10, row, col, heightName)) { height += 10; _Velocity.Y += 10f; if (height >= 50) { height = 0; col += 1; } } } if (Keyboard.GetState().IsKeyDown(Keys.Left)) { anim._IsPlaying = true; _isDown = false; _isLeft = true; _isRight = false; _isUp = false; if (GenFunctions.isMoveable(width - 10, row, col, widthName)) { width -= 10; _Velocity.X -= 10f; if (width <= 0) { width = 50; width -= 1; } } } if (Keyboard.GetState().IsKeyDown(Keys.Right)) { anim._IsPlaying = true; _isDown = false; _isLeft = false; _isRight = true; _isUp = false; if (GenFunctions.isMoveable(width + 10, row, col, widthName)) { width += 10; _Velocity.X += 10f; if (width >= 50) { width = 0; width += 1; } } } if (Keyboard.GetState().IsKeyDown(Keys.Up)) { anim._IsPlaying = true; _isDown = false; _isLeft = false; _isRight = false; _isUp = true; if (GenFunctions.isMoveable(height - 10, row, col, heightName)) { height -= 10; _Velocity.Y -= 10f; if (height <= 0) { height = 50; col -= 1; } } } if (_currentPressed.IsKeyDown(Keys.Z) && _prevPressed.IsKeyUp(Keys.Z)) { if (_inMenu) { _isPaused = false; _inGame = true; _inMenu = false; _inBattle = false; } else { _isPaused = true; _inGame = false; _inMenu = true; _inBattle = false; } } _prevPressed = _currentPressed; //////////////////////////testing battle if (Keyboard.GetState().IsKeyDown(Keys.B)) { _BattleMenuLeft = true; _BattleMenuUp = true; _BattleMenuRight = false; _BattleStartMenu = true; _ItemMenu = false; _inBattle = true; _BattleMovesMenu = false; _inGame = false; } }
public void Update(GameTime gameTime) { _words = GenFunctions.returnList(_wordsE, _wordsJ, _wordsP); //_words = _wordsP; }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { RenderTargetBinding[] activeTarget = GraphicsDevice.GetRenderTargets(); GraphicsDevice.SetRenderTarget(tempRender); GraphicsDevice.Clear(Color.CadetBlue); //temp render spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.AnisotropicWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Matrix.CreateScale(camera._fZoomLevel)); landmap.Draw(spriteBatch, camera._drawLocation); spriteBatch.End(); //player spriteBatch.Begin(); if (handleInput._isUp) { cycle.Draw(spriteBatch, camera._drawLocation, animUp); } if (handleInput._isDown) { cycle.Draw(spriteBatch, camera._drawLocation, animDown); } if (handleInput._isLeft) { cycle.Draw(spriteBatch, camera._drawLocation, animLeft); } if (handleInput._isRight) { cycle.Draw(spriteBatch, camera._drawLocation, animRight); } spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Matrix.CreateScale(camera._fZoomLevel)); overLay.Draw(spriteBatch, camera._drawLocation); spriteBatch.End(); GraphicsDevice.SetRenderTargets(activeTarget); GraphicsDevice.Clear(Color.LightGray); //Battles if (handleInput._inBattle) { if (transitionStart <= transitionEnd) { spriteBatch.Begin(); transition.Draw(spriteBatch, new Vector2(0, 0), 0.0f, 1.0f, SpriteEffects.None, 0.0f); spriteBatch.End(); transitionStart++; } else { spriteBatch.Begin(); //background battleBackGround.Draw(spriteBatch, new Vector2(0, 100), 0.0f, 1.0f, SpriteEffects.None, 0.0f); textBoxBackground.Draw(spriteBatch, new Vector2(0, 0), 0.0f, 1.0f, SpriteEffects.None, 0.0f); //battle menu textReader.Draw(spriteBatch, handleInput, enemyHealthCalc); //you HealthBarOutline.Draw(spriteBatch, new Vector2(68, 469), 0.0f, 1.0f, SpriteEffects.None, 0.0f); yourHealth.Draw(spriteBatch, new Vector2(70, 470), 0.0f, 1.0f, SpriteEffects.None, 0.0f); squirtle.Draw(spriteBatch, new Vector2(50, 500), Color.White, 0.0f, 1.0f, SpriteEffects.None, 0.0f); //enemy HealthBarOutline.Draw(spriteBatch, new Vector2(368, 119), 0.0f, 1.0f, SpriteEffects.None, 0.0f); enemyHealth.Draw(spriteBatch, new Vector2(370, 120), 0.0f, 1.0f, SpriteEffects.None, 0.0f); enemySprite.Draw(spriteBatch, new Vector2(355, 160), 0.0f, 1.0f, SpriteEffects.None, 0.0f); spriteBatch.End(); if (attackDamageParticle) { damage.Draw(spriteBatch); turnTimer++; } if (enemyAttackDamageParticle) { enemyDamage.Draw(spriteBatch); enemyTurnTimer++; } } } if (!handleInput._inBattle) { if (transitionStart <= transitionEnd) { spriteBatch.Begin(); transition.Draw(spriteBatch, new Vector2(0, 0), 0.0f, 1.0f, SpriteEffects.None, 0.0f); spriteBatch.End(); transitionStart++; } else { spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.AnisotropicWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Matrix.CreateScale(camera._fZoomLevel)); grayScale.CurrentTechnique.Passes[0].Apply(); spriteBatch.Draw(tempRender, new Rectangle(0, 0, tempRender.Width, tempRender.Height), Color.White); spriteBatch.End(); spriteBatch.Begin(); if (ghostDrawn == 0) { effect = GenFunctions.RandomSpritesEffects(); ghostDrawn++; } if (ghostUp) { ghost.Draw(spriteBatch, new Vector2(ghostLocX, ghostLocY), 0.0f, ghostSize, effect, 0.0f); } textReader.Draw(spriteBatch, handleInput); spriteBatch.End(); } } //handle main menu input if ((handleInput._inMenu) && (!handleInput._isPaused) && (!handleInput._inGame) && (!handleInput._inBattle)) { spriteBatch.Begin(); mainMenuBackground.Draw(spriteBatch, new Vector2(0, 0), 0.0f, 1.0f, SpriteEffects.None, 0.0f); textReader.Draw(spriteBatch, handleInput); spriteBatch.End(); } //fps fpsCounter.Draw(gameTime, spriteBatch, textReader._inGameFont); base.Draw(gameTime); }
/// <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); }