/// <summary> /// handles all the drawing of effects , bullets and manages the animations of a turn /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void battleformTimer_Tick(object sender, EventArgs e) { bool animationsDone; bool continueFight; // run all current effects to see if graphics are all done animationsDone = currentGame.ProcessWeaponEffects(); //store results //check results from effects if (!animationsDone) { //animations are finished //run clean up from attack and store result animationsDone = currentGame.ProcessGravity(); //update screen DrawBackground(); DrawGameplay(); // trigger redraw of screen displayPanel.Invalidate(); //check to see if anything moved from gravity effects from clean up if (animationsDone) { //if tanks moved from gavity return; } else { // nothing moved from gavity battleformTimer.Enabled = false; // move through the game cycle as currentplayers turn is over continueFight = currentGame.EndTurn(); if (continueFight) { // round not over yet or no winner NewTurn(); } else { // round over , winner is clear //close form Dispose(); //move to the next round //currentGame.NextRound(); Scoreboard thescore = new Scoreboard(currentGame); thescore.Show(); return; } // end of continueFight check } // end of animationsDone gravity check } // end of animationsDone chech else { // attack animations are still ongoing DrawGameplay(); // draw animations and trigger redraw on screen displayPanel.Invalidate(); return; } }
/// <summary> /// Handles the animation and physics logic /// </summary> private void timer1_Tick(object sender, EventArgs e) { //if all attack animations have ended if (!currentGame.ProcessWeaponEffects()) { currentGame.ProcessGravity(); //handle all the after - attack gravity cleanup. //redraw everything after potentially moving terrain. DrawBackground(); DrawGameplay(); displayPanel.Invalidate();// method to trigger a redraw. //if some tanks were moved if (currentGame.ProcessGravity()) { return; } // if nothing moved then the turn will end, if there is no more turns the round is over. else { timer1.Enabled = false; if (currentGame.TurnOver()) { NewTurn(); } else { Dispose(); currentGame.NextRound(); return; } } } //Otherwise, attack animations are still ongoing. else { DrawGameplay(); displayPanel.Invalidate(); return; } }