Exemplo n.º 1
0
        protected virtual void InitializeBullet(GenericStage stage, bool isUserBullet)
        {
            switch (this.Type)
            {
            case BulletType.PrimaryUser:
                this.SpriteImage = Resource.bullet01;
                break;

            case BulletType.PrimaryEnemy:
                this.SpriteImage = Resource.bullet02;
                break;

            case BulletType.Laser:
                this.SpriteImage = Resource.Bullet03;
                break;

            case BulletType.AlphaStar:
                this.SpriteImage = Resource.bullet01;
                break;

            default:
                this.SpriteImage = Resource.bullet01;
                break;
            }
        }
Exemplo n.º 2
0
        void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            try
            {
                if (game.Stage.StageImage != null)
                {
                    e.Graphics.DrawImage(game.Stage.StageImage, 0, 0, drX, drY);
                }
                GenericStage stage = game.Stage as GenericStage;
                if (stage != null)
                {
                    e.Graphics.FillRectangle(Brushes.Snow, 0, 0, 100, 40);
                    e.Graphics.DrawString("Energia: " + stage.User.Energy.ToString(), fontLive, Brushes.Black, 5f, 5f);
                    e.Graphics.DrawString("Inimigos: " + stage.Enemies.Count.ToString(), fontLive, Brushes.Black, 5f, 20f);
                    e.Graphics.DrawString("Itens: " + stage.Items.Count.ToString(), fontLive, Brushes.Black, 5f, 35f);
                }

                if (game.Stage.IsPaused)
                {
                    e.Graphics.DrawString("PAUSED", fontLive, Brushes.BlueViolet, 390f, 290f);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        public void AddBullets(List <Bullet> lstBullets, Vector2D v2dPosition, GenericStage stage, bool isUserBullet)
        {
            Vector2D velocity = this.InitialVelocity;
            Vector2D incPos   = this.Increment;

            if (this.fint_Quantity % 2 == 0)
            {
                velocity.X -= incPos.X;
                incPos.X   += this.Increment.X;
            }

            if (fbln_IsParalel)
            {
                #region fbln_IsParalel
                Vector2D finalPosition = v2dPosition;
                for (int i = 0; i < this.fint_Quantity; i++)
                {
                    lstBullets.Add(new Bullet(finalPosition, this.fblt_Type, this.fdbl_Force, this.InitialVelocity, stage, isUserBullet));

                    if (finalPosition.X <= v2dPosition.X)
                    {
                        finalPosition.X += incPos.X;
                        finalPosition.Y += incPos.Y;
                    }
                    else
                    {
                        finalPosition.X -= incPos.X;
                    }
                    incPos.X += this.Increment.X;
                }
                #endregion
            }
            else
            {
                #region else
                for (int i = 0; i < this.fint_Quantity; i++)
                {
                    lstBullets.Add(new Bullet(v2dPosition, this.fblt_Type, this.fdbl_Force, velocity, stage, isUserBullet));

                    if (velocity.X <= this.InitialVelocity.X)
                    {
                        velocity.X += incPos.X;
                    }
                    else
                    {
                        velocity.X -= incPos.X;
                    }

                    incPos.X += this.Increment.X;
                }
                #endregion
            }
        }
Exemplo n.º 4
0
        void game_OnCheckGameInputs(MainGameEventArgs e)
        {
            WinAPIUtil.POINT pt    = WinAPIUtil.GetCursorPos();
            GenericStage     stage = e.Game.Stage as GenericStage;

            if (stage != null)
            {
                stage.NextUserPosition = new Vector2D(
                    this.GetXWithAspect(pt.x - this.Left),
                    stage.Position.Y + this.GetYWithAspect(pt.y - (this.Top + 20)));
            }
        }
Exemplo n.º 5
0
        public Bullet(Vector2D position, BulletType type, double force, Vector2D velocity, GenericStage stage, bool isUserBullet)
        {
            this.Position = position;
            this.emnType  = type;
            this.Force    = force;
            this.Velocity = velocity;

            this.InitializeBullet(stage, isUserBullet);
            this.Heigth = this.SpriteImage.Height;
            this.Width  = this.SpriteImage.Width;
        }
Exemplo n.º 6
0
        public CombatStatus Update(SpaceShip user, GenericStage stage, double timeElapsed)
        {
            SpaceShip enemy = this;

            this.Update(timeElapsed);

            if (this.Position.X >= 800)
            {
                this.Velocity.X  = -this.Velocity.X;
                this.Position.Y += 34;
            }
            else if (this.Position.X <= 0)
            {
                this.Velocity.X  = -this.Velocity.X;
                this.Position.Y += 34;
            }
            if (this.Position.Y >= (stage.Position.Y + 600))
            {
                this.Velocity.Y = -this.Velocity.Y;
                this.BulletSettings.InitialVelocity.Y = -this.BulletSettings.InitialVelocity.Y;
            }
            else if (this.Position.Y >= (stage.Position.Y + 600))
            {
                this.Velocity.Y = -this.Velocity.Y;
                this.BulletSettings.InitialVelocity.Y = -this.BulletSettings.InitialVelocity.Y;
            }
            if (this.Position.Y >= (stage.Position.Y + 800))
            {
                this.Velocity.Y = -this.Velocity.Y;
                this.BulletSettings.InitialVelocity.Y = -this.BulletSettings.InitialVelocity.Y;
                return(CombatStatus.MeDie);
            }
            if (this.Position.Y <= stage.Position.Y)
            {
                this.Velocity.Y = -this.Velocity.Y;
                this.BulletSettings.InitialVelocity.Y = -this.BulletSettings.InitialVelocity.Y;
            }

            if (this.Position.Y > stage.Position.Y && this.Position.Y < (stage.Position.Y + 630))
            {
                if (TimeAcummulator.IsOverflow)
                {
                    this.BulletSettings.InitialVelocity = user.Position - this.Position;
                    //this.BulletSettings.InitialVelocity = this.BulletSettings.InitialVelocity.GetNormal() * this.BulletSettings.NominalVelocity;
                    this.BulletSettings.InitialVelocity = this.BulletSettings.InitialVelocity.GetMultNormal(this.BulletSettings.NominalVelocity);
                    Vector2D posB;
                    posB.X = this.Position.X + this.AddPosBullet;
                    posB.Y = this.Position.Y;
                    this.BulletSettings.AddBullets(stage.EnemiesBullets, posB, stage, false);
                }
            }

            if (this.HasItem)
            {
                this.Item.Position = this.Position;
            }

            CombatStatus statusUser = user.VerifyCombat(this);

            if (statusUser != CombatStatus.None)
            {
                stage.Explosions.Add(new Explosion(user.Position, ExplosionType.Two));
            }
            return(statusUser);
        }