예제 #1
0
 /// <summary>
 /// Create an alive object
 /// </summary>
 /// <param name="team">the team of the game object</param>
 /// <param name="coords">the position of the game object</param>
 /// <param name="drawable">the image to draw</param>
 /// <param name="soundHandler">the song container</param>
 /// <param name="life">the life of the imageObject</param>
 public AliveObject(Team team, Vector2D coords, Drawable drawable, SoundHandler soundHandler, int life) :
     base(team, coords, drawable)
 {
     Coords      -= new Vector2D(ImageDimentions.X / 2, 0);
     SoundHandler = GameException.RequireNonNull(soundHandler);
     Life         = (int)GameException.RequirePositive(life);
 }
예제 #2
0
 /// <summary>
 /// Create an alive object
 /// </summary>
 /// <param name="team">the team of the game object</param>
 /// <param name="coords">the position of the game object</param>
 /// <param name="drawable">the image to draw</param>
 /// <param name="soundHandler">the song container</param>
 /// <param name="life">the life of the imageObject</param>
 /// <param name="speed">move speed in pixels</param>
 /// <param name="speedDecalage">move acceleration in pixels when the direction changes</param>
 public MovingObject(Team team, Vector2D coords, Drawable drawable, SoundHandler soundHandler, int life,
                     double speed, double speedDecalage) :
     base(team, coords, drawable, soundHandler, life)
 {
     Speed         = GameException.RequirePositive(speed);
     SpeedDecalage = GameException.RequirePositive(speedDecalage);
 }
예제 #3
0
 /// <summary>
 /// Create an animation from an image that can be divided in few images
 /// </summary>
 /// <param name="image">the graphics</param>
 /// <param name="lines">the numbers of lines in a single row</param>
 /// <param name="columns">the numbers of columns in a single line</param>
 public Animation(Bitmap image, int lines, int columns) :
     base(
         image,
         image.Width / (int)GameException.RequirePositive(columns),
         image.Height / (int)GameException.RequirePositive(lines)
         )
 {
     this.lines   = lines;
     this.columns = columns;
     Indexes      = new Vector2D(0, 0);
 }
예제 #4
0
        /// <summary>
        /// Create shooter object
        /// </summary>
        /// <param name="src">initial position of the ennemy</param>
        /// <param name="dst">destination to reach before horizontal movement</param>
        /// <param name="drawable">image to draw</param>
        /// <param name="missileImage">projectile image to draw</param>
        /// <param name="speed">move speed in pixels</param>
        /// <param name="speedDecalage">move acceleration in pixels when the direction changes</param>
        /// <param name="shootPercentage">percentage to shoot by second between 0 and 100</param>
        /// <param name="life">life of the imageObject</param>
        public EnnemyObject(Vector2D src, Vector2D dst, Drawable drawable, Drawable missileImage, double speed,
                            double speedDecalage, int shootPercentage, int life) :
            base(Team.ENNEMY, GameException.RequireNonNull(src), drawable, ENNEMY_SOUNDS, speed, speedDecalage, life)
        {
            DestinationCoords = GameException.RequireNonNull(dst);
            MissileImage      = missileImage;
            ShootPercentage   = (int)GameException.RequirePositive(shootPercentage);

            // Every seconds, ...
            Timer = new Timer {
                Interval = 1000
            };

            // ..., the ennemy can try a shoot
            Timer.Elapsed += (object sender, ElapsedEventArgs e) => {
                TimeToShoot = true;
                Timer.Stop();
            };
        }
예제 #5
0
 /// <summary>
 /// Create a Drawable, ready to be drawed
 /// </summary>
 /// <param name="image">the first image that we have to draw</param>
 /// <param name="width">the width of the image</param>
 /// <param name="height">the height of the image</param>
 protected Drawable(Bitmap image, int width, int height)
 {
     Image  = GameException.RequireNonNull(image);
     Width  = (int)GameException.RequirePositive(width);
     Height = (int)GameException.RequirePositive(height);
 }