示例#1
0
        /// <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;
            }
        }