/// <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) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); PreviousScreen = CurrentScreen; if (CurrentScreen == Screens.WorldScreen) { CurrentScreen = WorldScreen.Update(gameTime); } else if (CurrentScreen == Screens.FightingScreen) { CurrentScreen = FightingScreen.Update(gameTime); } if (PreviousScreen != CurrentScreen && CurrentScreen == Screens.FightingScreen) { Random rand = new Random(gameTime.TotalGameTime.Milliseconds); int i = rand.Next(0, Monsters.Count); rand = new Random((int)gameTime.TotalGameTime.TotalSeconds); int lvl = rand.Next(1, 5); List<Attack> attacks = new List<Attack>(); attacks.Add(new Attack(15, "Tackle")); attacks.Add(new Attack(0, "Growl")); Monster monster = (Monster)Monsters[i].Clone(); monster.Reset(lvl, attacks); Battle battle = new Battle(Player, monster); FightingScreen.Reinitialize(battle); } // Updating parent class base.Update(gameTime); }
public void Reinitialize(Battle battle) { this.Battle = battle; DisplayText = ""; FightOver = false; }