/// <summary>
        /// Стрильба
        /// </summary>
        /// <param name="nameTank">Имя типа танка</param>
        /// <param name="velocity">Скорость снаряда</param>
        protected void Fire(KeyObjGame nameTank, int velocity)
        {
            // Если пуля еще летит
            if (shell == null || !shell.IsAlive)
            {
                // Создание снаряда в зависимости от направления танка
                switch (direction)
                {
                case Direction.Up:
                    shell = new AnimationDetonationShell(new Rectangle(spriteRectangle.Left + (spriteRectangle.Width / 2 - SizeGame.WidtchShell / 2), spriteRectangle.Top - SizeGame.HeighShell, SizeGame.WidtchShell, SizeGame.HeighShell), velocity, this.direction, nameTank);
                    break;

                case Direction.Right:
                    shell = new AnimationDetonationShell(new Rectangle(spriteRectangle.Right + 1, spriteRectangle.Top + (spriteRectangle.Height / 2 - SizeGame.HeighShell / 2), SizeGame.HeighShell, SizeGame.WidtchShell), velocity, this.direction, nameTank);
                    break;

                case Direction.Down:
                    shell = new AnimationDetonationShell(new Rectangle(spriteRectangle.Left + (spriteRectangle.Width / 2 - SizeGame.WidtchShell / 2), spriteRectangle.Bottom, SizeGame.WidtchShell, SizeGame.HeighShell), velocity, this.direction, nameTank);
                    break;

                case Direction.Left:
                    shell = new AnimationDetonationShell(new Rectangle(spriteRectangle.Left - SizeGame.WidtchShell, spriteRectangle.Top + (spriteRectangle.Height / 2 - SizeGame.HeighShell / 2), SizeGame.HeighShell, SizeGame.WidtchShell), velocity, this.direction, nameTank);
                    break;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Конструктор
        /// </summary>
        /// <param name="rect">Прямоугольник описывающий позицию обьекта на екране, ширину и высоту</param>
        /// <param name="velocity">Скорость</param>
        /// <param name="direction">Направление движения</param>
        /// <param name="nameTank">Ссылка на танк которому пренадлежит снаряд</param>
        public ShellObj(Rectangle rect, int velocity, Direction direction, KeyObjGame nameTank)
            : base(rect, velocity, direction)
        {
            isAlive        = true;
            this.nameTank  = nameTank;
            this.velocity  = velocity;
            this.direction = direction;

            // Загрузка картинок в зависимости от направления снаряда
            switch (direction)
            {
            case Direction.Up:
                spriteImage = Properties.Resources.BulletUp;
                break;

            case Direction.Right:
                spriteImage = Properties.Resources.BulletRight;
                break;

            case Direction.Down:
                spriteImage = Properties.Resources.BulletDown;
                break;

            case Direction.Left:
                spriteImage = Properties.Resources.BulletLeft;
                break;
            }
            // Добавление в список обектов игры
            Level.DictionaryObjGame[KeyObjGame.ShellObj].Add(this);
        }
Esempio n. 3
0
        /// <summary>
        /// Стрильба
        /// </summary>
        /// <param name="nameTank">Имя типа танка</param>
        /// <param name="velocity">Скорость снаряда</param>
        protected void Fire(KeyObjGame nameTank)
        {
            // Если пуля еще летит
            if (shell == null || !shell.IsAlive)
            {
                if (nameTank == KeyObjGame.Player)
                {
                    SoundGame.SoundFire();
                }
                // Создание снаряда в зависимости от направления танка
                switch (direction)
                {
                case Direction.Up:
                    shell = new CollisionShell(new Rectangle(spriteRectangle.Left + (spriteRectangle.Width / 2 - SettingsGame.WidtchShell / 2), spriteRectangle.Top - SettingsGame.HeighShell, SettingsGame.WidtchShell, SettingsGame.HeighShell), this.velosityShel, this.direction, nameTank);
                    break;

                case Direction.Right:
                    shell = new CollisionShell(new Rectangle(spriteRectangle.Right + 1, spriteRectangle.Top + (spriteRectangle.Height / 2 - SettingsGame.HeighShell / 2), SettingsGame.HeighShell, SettingsGame.WidtchShell), this.velosityShel, this.direction, nameTank);
                    break;

                case Direction.Down:
                    shell = new CollisionShell(new Rectangle(spriteRectangle.Left + (spriteRectangle.Width / 2 - SettingsGame.WidtchShell / 2), spriteRectangle.Bottom, SettingsGame.WidtchShell, SettingsGame.HeighShell), this.velosityShel, this.direction, nameTank);
                    break;

                case Direction.Left:
                    shell = new CollisionShell(new Rectangle(spriteRectangle.Left - SettingsGame.WidtchShell, spriteRectangle.Top + (spriteRectangle.Height / 2 - SettingsGame.HeighShell / 2), SettingsGame.HeighShell, SettingsGame.WidtchShell), this.velosityShel, this.direction, nameTank);
                    break;
                }
            }
        }
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="rect">Прямоугольник описывающий позицию обьекта на екране, ширину и высоту</param>
 /// <param name="velocity">Скорость</param>
 /// <param name="direction">Направление движения</param>
 /// <param name="nameTank">Ссылка на танк которому пренадлежит снаряд</param>
 public AnimationDetonationShell(Rectangle rect, int velocity, Direction direction, KeyObjGame nameTank)
     : base(rect, velocity, direction, nameTank)
 {
 }
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="rect">Прямоугольник описывающий позицию обьекта на екране, ширину и высоту</param>
 /// <param name="velocity">Скорость</param>
 /// <param name="direction">Направление движения</param>
 /// <param name="nameTank">Ссылка на танк которому пренадлежит снаряд</param>
 public CollisionShell(Rectangle rect, int velocity, Direction direction, KeyObjGame nameTank)
     : base(rect, velocity, direction, nameTank)
 {
     delay = 0;
 }