예제 #1
0
        public void initializeDamageClouds(int maxParticles, int particlesPerSecond, Color cloudColor)
        {
            damageClouds = new SmokeCloud(game, new Vector2(tankPosition.X + tankPic.Width / 2, tankPosition.Y + tankPic.Height / 2),
                                          maxParticles, particlesPerSecond, cloudColor);
            damageClouds.AutoInitialize(game.GraphicsDevice, game.Content, TankGame.spriteBatch);

            damageClouds.UpdateOrder = 100;
            damageClouds.DrawOrder   = 100;
            damageClouds.Visible     = true;
        }
예제 #2
0
        public Tank(TankGame game, Vector2 tankPosition, float turretAngle)
            : base(game)
        {
            this.game               = game;
            this.tankPosition       = tankPosition;
            turretPosition          = new Vector2(tankPosition.X + 40, tankPosition.Y + 25);
            this.turretAngle        = turretAngle;
            health                  = 200;
            turnTime                = 0;
            moveLimit               = 0;
            originalTurretDirection = new Vector2(0, 1);
            turretDirection         = new Vector2((float)(Math.Cos(-turretAngle) * originalTurretDirection.X - Math.Sin(-turretAngle) * originalTurretDirection.Y),
                                                  (float)(Math.Sin(-turretAngle) * originalTurretDirection.X + Math.Cos(-turretAngle) * originalTurretDirection.Y));
            bullet       = new Bullet(game);
            type         = BulletType.BasicBullet;
            inventory    = new Inventory(game);
            damageClouds = null;
            timer        = 0.0f;

            currentTankState = TankState.Normal;
        }
예제 #3
0
파일: Tank.cs 프로젝트: Stran6/TankGame
        public void initializeDamageClouds(int maxParticles, int particlesPerSecond, Color cloudColor)
        {
            damageClouds = new SmokeCloud(game, new Vector2(tankPosition.X + tankPic.Width / 2, tankPosition.Y + tankPic.Height / 2),
                maxParticles, particlesPerSecond, cloudColor);
            damageClouds.AutoInitialize(game.GraphicsDevice, game.Content, TankGame.spriteBatch);

            damageClouds.UpdateOrder = 100;
            damageClouds.DrawOrder = 100;
            damageClouds.Visible = true;
        }
예제 #4
0
파일: Tank.cs 프로젝트: Stran6/TankGame
        public override void Update(GameTime gameTime)
        {
            keyState = Keyboard.GetState();
            
            tankRect.X = (int)tankPosition.X;
            tankRect.Y = (int)tankPosition.Y;

            tankPosition.Y += tempSpeed;
            
            if (bullet.type != BulletType.NullBullet)
            {
                bullet.Update(gameTime);
            }
            
            #region Damage Clouds & Sparks

            if (explosionTimer > 0)
            {
                if (health < 25 & !showYourFateIsSealedClouds)
                {
                    if (damageClouds != null)
                    {
                        damageClouds.Dispose();
                        damageClouds = null;
                    }

                    while (sparks.Count > 0)
                    {
                        sparks[0].Dispose();
                        sparks.RemoveAt(0);
                    }

                    showLightDamageClouds = false;
                    showDamageClouds = false;
                    showSevereClouds = false;
                    showCritialClouds = false;
                    showYourFateIsSealedClouds = true;
                }
                else if (health >= 25 && health < 75 & !showCritialClouds)
                {
                    if (damageClouds != null)
                    {
                        damageClouds.Dispose();
                        damageClouds = null;
                    }

                    while (sparks.Count > 0)
                    {
                        sparks[0].Dispose();
                        sparks.RemoveAt(0);
                    }

                    showLightDamageClouds = false;
                    showDamageClouds = false;
                    showSevereClouds = false;
                    showCritialClouds = true;
                    showYourFateIsSealedClouds = false;
                }
                else if (health >= 75 && health < 125 & !showSevereClouds)
                {
                    if (damageClouds != null)
                    {
                        damageClouds.Dispose();
                        damageClouds = null;
                    }

                    while (sparks.Count > 0)
                    {
                        sparks[0].Dispose();
                        sparks.RemoveAt(0);
                    }

                    showLightDamageClouds = false;
                    showDamageClouds = false;
                    showSevereClouds = true;
                    showCritialClouds = false;
                    showYourFateIsSealedClouds = false;
                }
                else if (health >= 125 && health < 175 & !showDamageClouds)
                {
                    if (damageClouds != null)
                    {
                        damageClouds.Dispose();
                        damageClouds = null;
                    }

                    while (sparks.Count > 0)
                    {
                        sparks[0].Dispose();
                        sparks.RemoveAt(0);
                    }

                    showLightDamageClouds = false;
                    showDamageClouds = true;
                    showSevereClouds = false;
                    showCritialClouds = false;
                    showYourFateIsSealedClouds = false;
                }
                else if (health >= 175 && health < 200 & !showLightDamageClouds)
                {
                    if (damageClouds != null)
                    {
                        damageClouds.Dispose();
                        damageClouds = null;
                    }

                    while (sparks.Count > 0)
                    {
                        sparks[0].Dispose();
                        sparks.RemoveAt(0);
                    }

                    showLightDamageClouds = true;
                    showDamageClouds = false;
                    showSevereClouds = false;
                    showCritialClouds = false;
                    showYourFateIsSealedClouds = false;
                }
                else if (health >= 200)
                {
                    if (damageClouds != null)
                    {
                        damageClouds.Dispose();
                        damageClouds = null;
                    }

                    while (sparks.Count > 0)
                    {
                        sparks[0].Dispose();
                        sparks.RemoveAt(0);
                    }

                    showLightDamageClouds = false;
                    showDamageClouds = false;
                    showSevereClouds = false;
                    showCritialClouds = false;
                    showYourFateIsSealedClouds = false;
                }

                if (showLightDamageClouds && damageClouds == null)
                {
                    initializeDamageClouds(1, 1, Color.White);
                    initializeSpark(1, 5, 2.0f);
                }
                else if (showDamageClouds && damageClouds == null)
                {
                    initializeDamageClouds(5, 5, Color.LightGray);
                    initializeSpark(2, 5, 1.6f);
                }
                else if (showSevereClouds && damageClouds == null)
                {
                    initializeDamageClouds(10, 10, Color.Gray);
                    initializeSpark(3, 10, 1.2f);
                }
                else if (showCritialClouds && damageClouds == null)
                {
                    initializeDamageClouds(20, 20, Color.DarkGray);
                    initializeSpark(4, 15, .8f);
                }
                else if (showYourFateIsSealedClouds && damageClouds == null)
                {
                    initializeDamageClouds(200, 200, Color.DarkSlateGray);
                    initializeSpark(6, 20, .4f);
                }

                if (damageClouds != null)
                {
                    damageClouds.changeEmitterPosition(new Vector2(tankPosition.X + tankPic.Width / 2, tankPosition.Y + tankPic.Height / 2));
                    damageClouds.ParticleUpdate(gameTime);
                }

                 foreach(Spark s in sparks)
                 {
                     s.changeEmitterPosition(new Vector2(tankPosition.X + tankPic.Width / 2, tankPosition.Y + tankPic.Height / 2));
                 }
            }
            else
            {
                if (damageClouds != null)
                {
                    damageClouds.Dispose();
                    damageClouds = null;
                }

                while(sparks.Count > 0)
                {
                    sparks[0].Dispose();
                    sparks.RemoveAt(0);
                }
            }

            #endregion Damage Clouds & Sparks

            if (recoil)
            {
                tankRecoil();
            }

            if (tanksplosion != null)
            {
                explosionTimer -= (float)gameTime.ElapsedGameTime.TotalSeconds;
            }

            base.Update(gameTime);
        }
예제 #5
0
파일: Tank.cs 프로젝트: Stran6/TankGame
        public Tank(TankGame game, Vector2 tankPosition, float turretAngle)
            : base(game)
        { 
            this.game = game;
            this.tankPosition = tankPosition;
            turretPosition = new Vector2(tankPosition.X + 40, tankPosition.Y + 25);
            this.turretAngle = turretAngle;
            health = 200;
            turnTime = 0;
            moveLimit = 0;
            originalTurretDirection = new Vector2(0, 1);
            turretDirection = new Vector2((float)(Math.Cos(-turretAngle) * originalTurretDirection.X - Math.Sin(-turretAngle) * originalTurretDirection.Y),
                (float)(Math.Sin(-turretAngle) * originalTurretDirection.X + Math.Cos(-turretAngle) * originalTurretDirection.Y));
            bullet = new Bullet(game);
            type = BulletType.BasicBullet;
            inventory = new Inventory(game);
            damageClouds = null;
            timer = 0.0f;

            currentTankState = TankState.Normal;
        }
예제 #6
0
        public override void Update(GameTime gameTime)
        {
            keyState = Keyboard.GetState();

            tankRect.X = (int)tankPosition.X;
            tankRect.Y = (int)tankPosition.Y;

            tankPosition.Y += tempSpeed;

            if (bullet.type != BulletType.NullBullet)
            {
                bullet.Update(gameTime);
            }

            #region Damage Clouds & Sparks

            if (explosionTimer > 0)
            {
                if (health < 25 & !showYourFateIsSealedClouds)
                {
                    if (damageClouds != null)
                    {
                        damageClouds.Dispose();
                        damageClouds = null;
                    }

                    while (sparks.Count > 0)
                    {
                        sparks[0].Dispose();
                        sparks.RemoveAt(0);
                    }

                    showLightDamageClouds      = false;
                    showDamageClouds           = false;
                    showSevereClouds           = false;
                    showCritialClouds          = false;
                    showYourFateIsSealedClouds = true;
                }
                else if (health >= 25 && health < 75 & !showCritialClouds)
                {
                    if (damageClouds != null)
                    {
                        damageClouds.Dispose();
                        damageClouds = null;
                    }

                    while (sparks.Count > 0)
                    {
                        sparks[0].Dispose();
                        sparks.RemoveAt(0);
                    }

                    showLightDamageClouds      = false;
                    showDamageClouds           = false;
                    showSevereClouds           = false;
                    showCritialClouds          = true;
                    showYourFateIsSealedClouds = false;
                }
                else if (health >= 75 && health < 125 & !showSevereClouds)
                {
                    if (damageClouds != null)
                    {
                        damageClouds.Dispose();
                        damageClouds = null;
                    }

                    while (sparks.Count > 0)
                    {
                        sparks[0].Dispose();
                        sparks.RemoveAt(0);
                    }

                    showLightDamageClouds      = false;
                    showDamageClouds           = false;
                    showSevereClouds           = true;
                    showCritialClouds          = false;
                    showYourFateIsSealedClouds = false;
                }
                else if (health >= 125 && health < 175 & !showDamageClouds)
                {
                    if (damageClouds != null)
                    {
                        damageClouds.Dispose();
                        damageClouds = null;
                    }

                    while (sparks.Count > 0)
                    {
                        sparks[0].Dispose();
                        sparks.RemoveAt(0);
                    }

                    showLightDamageClouds      = false;
                    showDamageClouds           = true;
                    showSevereClouds           = false;
                    showCritialClouds          = false;
                    showYourFateIsSealedClouds = false;
                }
                else if (health >= 175 && health < 200 & !showLightDamageClouds)
                {
                    if (damageClouds != null)
                    {
                        damageClouds.Dispose();
                        damageClouds = null;
                    }

                    while (sparks.Count > 0)
                    {
                        sparks[0].Dispose();
                        sparks.RemoveAt(0);
                    }

                    showLightDamageClouds      = true;
                    showDamageClouds           = false;
                    showSevereClouds           = false;
                    showCritialClouds          = false;
                    showYourFateIsSealedClouds = false;
                }
                else if (health >= 200)
                {
                    if (damageClouds != null)
                    {
                        damageClouds.Dispose();
                        damageClouds = null;
                    }

                    while (sparks.Count > 0)
                    {
                        sparks[0].Dispose();
                        sparks.RemoveAt(0);
                    }

                    showLightDamageClouds      = false;
                    showDamageClouds           = false;
                    showSevereClouds           = false;
                    showCritialClouds          = false;
                    showYourFateIsSealedClouds = false;
                }

                if (showLightDamageClouds && damageClouds == null)
                {
                    initializeDamageClouds(1, 1, Color.White);
                    initializeSpark(1, 5, 2.0f);
                }
                else if (showDamageClouds && damageClouds == null)
                {
                    initializeDamageClouds(5, 5, Color.LightGray);
                    initializeSpark(2, 5, 1.6f);
                }
                else if (showSevereClouds && damageClouds == null)
                {
                    initializeDamageClouds(10, 10, Color.Gray);
                    initializeSpark(3, 10, 1.2f);
                }
                else if (showCritialClouds && damageClouds == null)
                {
                    initializeDamageClouds(20, 20, Color.DarkGray);
                    initializeSpark(4, 15, .8f);
                }
                else if (showYourFateIsSealedClouds && damageClouds == null)
                {
                    initializeDamageClouds(200, 200, Color.DarkSlateGray);
                    initializeSpark(6, 20, .4f);
                }

                if (damageClouds != null)
                {
                    damageClouds.changeEmitterPosition(new Vector2(tankPosition.X + tankPic.Width / 2, tankPosition.Y + tankPic.Height / 2));
                    damageClouds.ParticleUpdate(gameTime);
                }

                foreach (Spark s in sparks)
                {
                    s.changeEmitterPosition(new Vector2(tankPosition.X + tankPic.Width / 2, tankPosition.Y + tankPic.Height / 2));
                }
            }
            else
            {
                if (damageClouds != null)
                {
                    damageClouds.Dispose();
                    damageClouds = null;
                }

                while (sparks.Count > 0)
                {
                    sparks[0].Dispose();
                    sparks.RemoveAt(0);
                }
            }

            #endregion Damage Clouds & Sparks

            if (recoil)
            {
                tankRecoil();
            }

            if (tanksplosion != null)
            {
                explosionTimer -= (float)gameTime.ElapsedGameTime.TotalSeconds;
            }

            base.Update(gameTime);
        }