Пример #1
0
        private void MoveBullets(
            ref Backdrop backdrop,
            ref GameSound sound)
        {
            Sprite tempCollision_s = null;

            try
            {
                for (int i = 0; i < this.count_i; i++)
                {
                    if (this.bullets_s[i].Visible)
                    {
                        if (this.bullets_s[i].Y < (this.screenHeight_i + this.bullets_s[i].Height))
                        {
                            this.bullets_s[i].Position(
                                this.bullets_s[i].X,
                                (this.bullets_s[i].Y + this.speed_i));
                        }
                        else
                        {
                            this.bullets_s[i].Visible = false;
                            this.shooting_s.Remove(this.bullets_s[i]);
                        }

                        tempCollision_s = this.bullets_s[i].Collision();

                        if (tempCollision_s != null &&
                            !this.aliens_s.Contains(tempCollision_s) &&
                            !backdrop.sprites.Contains(tempCollision_s))
                        {
                            this.bullets_s[i].Visible = false;
                            this.shooting_s.Remove(this.bullets_s[i]);

                            sound.PlayExplosion();
                            tempCollision_s.Visible = false;
                            tempCollision_s         = null;
                        }

                        tempCollision_s = null;
                    }
                    else
                    {
                        this.bullets_s[i].Position(
                            -(this.screenWidth_i),
                            -(this.screenHeight_i));
                    }
                }
            }
            catch (Exception ex)
            {
                this.exception_ex = ex;
            }
        }
Пример #2
0
        private void BulletUpdates(
            ref Backdrop backdrop,
            ref GameSound sound)
        {
            Sprite tempCollision_s = null;

            try
            {
                if (this.fire_bl)
                {
                    for (int i = 0; i < this.count_i; i++)
                    {
                        if (!this.bullets_s[i].Visible)
                        {
                            this.bullets_s[i].Visible = true;
                            sound.PlayFire();
                            break;
                        }
                    }

                    this.fire_bl = false;
                }

                for (int i = 0; i < this.count_i; i++)
                {
                    if (this.bullets_s[i].Visible)
                    {
                        if (this.bullets_s[i].Y > -(this.bullets_s[i].Height))
                        {
                            this.bullets_s[i].Position(
                                this.bullets_s[i].X,
                                (this.bullets_s[i].Y - this.speed_i));
                        }
                        else
                        {
                            this.misses_f++;
                            this.bullets_s[i].Visible = false;
                        }

                        tempCollision_s = this.bullets_s[i].Collision();

                        if (tempCollision_s != null
                            //&& tempCollision_s != this.player_s
                            && !backdrop.sprites.Contains(tempCollision_s))
                        {
                            this.hits_f++;
                            this.score_i += 100;
                            this.bullets_s[i].Visible = false;

                            sound.PlayExplosion();
                            tempCollision_s.Visible = false;
                            tempCollision_s         = null;
                        }
                    }
                    else
                    {
                        this.bullets_s[i].Position(
                            (this.player_s.X + (this.player_s.Width / 2)),
                            (this.player_s.Y + (this.player_s.Height / 2)));
                    }
                }
            }
            catch (Exception ex)
            {
                this.exception_ex = ex;
            }
        }