Example #1
0
        /// <summary>
        /// Method for drawing the tanks
        /// </summary>
        /// <param name="o"></param>
        /// <param name="e"></param>
        private void TankDrawer(object o, PaintEventArgs e)
        {
            Tank t = o as Tank;

            //Stops tank from updating anymore information if health equals zero
            if (t.HitPoints == 0)
            {
                DrawExplosion(t, e);
                return;
            }
            //Resets the tank frames when the tank isn't dead
            else if (TheController.TheWorld.TankExplosions.ContainsKey(t.ID) && (TheController.TheWorld.TankExplosions[t.ID].tankFrames != 0 && !t.Died))
            {
                TheController.TheWorld.ExplosionClearFrames(TheController.TheWorld.TankExplosions[t.ID]);
            }

            int tankWidth  = Constants.TankSize;
            int tankHeight = Constants.TankSize;

            // Gets color ID of the tank
            int colorID = TheController.GetColor(t.ID);

            //Determines tank color based on the color ID of the tank
            switch (colorID)
            {
            //Blue
            case 0:
                e.Graphics.DrawImage(sourceImageBlueTank, -(tankWidth / 2), -(tankHeight / 2), tankWidth, tankHeight);
                break;

            //Dark
            case 1:
                e.Graphics.DrawImage(sourceImageDarkTank, -(tankWidth / 2), -(tankHeight / 2), tankWidth, tankHeight);
                break;

            //Green
            case 2:
                e.Graphics.DrawImage(sourceImageGreenTank, -(tankWidth / 2), -(tankHeight / 2), tankWidth, tankHeight);
                break;

            //Light Green
            case 3:
                e.Graphics.DrawImage(sourceImageLightGreenTank, -(tankWidth / 2), -(tankHeight / 2), tankWidth, tankHeight);
                break;

            //Orange
            case 4:
                e.Graphics.DrawImage(sourceImageOrangeTank, -(tankWidth / 2), -(tankHeight / 2), tankWidth, tankHeight);
                break;

            //Purple
            case 5:
                e.Graphics.DrawImage(sourceImagePurpleTank, -(tankWidth / 2), -(tankHeight / 2), tankWidth, tankHeight);
                break;

            //Red
            case 6:
                e.Graphics.DrawImage(sourceImageRedTank, -(tankWidth / 2), -(tankHeight / 2), tankWidth, tankHeight);
                break;

            //Yellow
            case 7:
                e.Graphics.DrawImage(sourceImageYellowTank, -(tankWidth / 2), -(tankHeight / 2), tankWidth, tankHeight);
                break;
            }
        }