Ejemplo n.º 1
0
 public override void Remove()
 {
     ProjectileSpeedTimer.Stop();
     AddProjectileTimer.Stop();
     HomingMissileTimer.Stop();
     SlowAllTimer.Stop();
     Node.Fps = 30;
     //Timer.TimerSpeedModifier = 1f;
     //fireTimer.Stop();
     //fireTimer = null;
     Bar.Bars.Remove(ProjectileSpeedBar);
     Bar.Bars.Remove(AddProjectileBar);
     Bar.Bars.Remove(HomingMissileBar);
     Bar.Bars.Remove(InvulnAbilityBar);
     PlayerShips.Remove(this);
     Player.RemoveShip(this);
     this.Shield.Remove();
     this.Shield = null;
     //sidearm1.Remove();
     //sidearm2.Remove();
     base.Remove();
 }
Ejemplo n.º 2
0
        public PlayerShip(SpriteSheet spriteSheet)
            : base(spriteSheet)
        {
            PlayerShips.Add(this);
            this.Speed = Config.ShipSpeed;
            this.Health = Config.ShipHealth;
            this.MaxHealth = Config.ShipHealth;
            this.FireInterval = Config.PlayerFireInterval;
            //this.ExplosionSpriteSheet = Config.SmallExplosionSpriteSheet;

            this.FireAction = new FireAction(ProjectileBulletGreenBeam.FireBullet);

            this.Weapon = new WeaponAuto(this, FireInterval);

            InvulnerableTimer = new Timer();
            InvulnerableTimer.Fire += new NotifyHandler(InvulnerableTimer_Fire);
            this.InvulnerableTimer.Start(3);
            isInvulnerable = true;
            megaMagnetActive = false;

            laser = new Laser();
            ////ShieldBar = new Bar(400, 2, Color.RoyalBlue);
            //ShieldBar = new Bar(400, 2, new Color(65, 105, 225, 0));
            //ShieldBar.Position = new Vector2(200, 440);
            //ShieldBar.DrawCentered = true;

            ////HealthBar = new Bar(400, 2, Color.Red);
            //HealthBar = new Bar(400, 2, new Color(255, 0, 0, 0));
            //HealthBar.Position = new Vector2(200, 460);
            //HealthBar.DrawCentered = true;

            //WeaponBurst burstWeapon = new WeaponBurstWave(this, 0, 1, 0.14f);
            //this.Weapon = new WeaponAutoBurst(this, Config.PlayerFireInterval, burstWeapon);

            //this.FireAction = new FireAction(ProjectileMissile.FireMissile);
            //this.Weapon = new WeaponBurstWave(this, Config.WaveFireInterval, Config.WaveFireTotal, Config.WaveFireSpread);

            //WeaponBurst burstWeapon = new WeaponBurstWave(this, Config.WaveFireInterval, Config.WaveFireTotal, Config.WaveFireSpread);
            //this.Weapon = new WeaponAutoBurst(this, Config.WaveFireInterval * Config.WaveFireTotal, burstWeapon);

            //spawn sidearms
            //sidearm1 = new Sidearm(Config.BuddySpriteSheet, this);
            //sidearm1.Position = this.Position;
            //sidearm1.SetParent(this);

            //sidearm1 = new Sidearm(Config.BulletSheetGreenLaser, this, new Vector2(30, 0));
            //sidearm1.Position = new Vector2(Config.WorldBoundsX / 2, Config.WorldBoundsY / 2 - this.Sprite.Origin.Y);
            //sidearm1.SetParent(this);

            //sidearm2 = new Sidearm(Config.BulletSheetGreenLaser, this, new Vector2(-30, 0));
            //sidearm2.Position = new Vector2(Config.WorldBoundsX / 2, Config.WorldBoundsY / 2 - this.Sprite.Origin.Y);
            //sidearm2.SetParent(this);

            this.Position = new Vector2(Config.WorldBoundsX / 2, Config.WorldBoundsY / 2 - this.Sprite.Origin.Y);
            this.baseTexture = new Sprite(Config.CurrentShipBase);
            this.baseTexture.Color = Config.CurrentShipColor;
            //GameStateManagementGame.Instance.soundManager.PlaySound("ShipSpawn", 0.5f);

            ProjectileSpeedTimer = new Timer();
            ProjectileSpeedTimer.Fire += new NotifyHandler(ProjectileSpeedTimer_Fire);

            AddProjectileTimer = new Timer();
            AddProjectileTimer.Fire += new NotifyHandler(AddProjectileTimer_Fire);

            HomingMissileTimer = new Timer();
            HomingMissileTimer.Fire += new NotifyHandler(HomingMissileTimer_Fire);

            SlowAllTimer = new Timer();
            SlowAllTimer.Fire += new NotifyHandler(SlowAllTimer_Fire);

            Shield = new PlayerShield(Config.ShipShield, this);
            //PlayerShips.Add(Shield);

            //////////AI
            if (Config.AIControlled)
            {
                //this.Speed = 8f;
                //moveTo = new Vector2(Config.Rand.Next(50, 1550), Config.Rand.Next(50, 910));
                this.Weapon.StartFire();
                ////this.fireTimer = new Timer();
                ////this.fireTimer.Fire += new NotifyHandler(fireTimer_Fire);
                ////this.fireTimer.Start(FireInterval);
            }
            ////////////

        }
Ejemplo n.º 3
0
        public override void Update(GameTime gameTime)
        {
            //this.baseTexture.ColorLerp(Config.DamageColor, Config.ShipColor, ((float)this.Health / Config.ShipHealth));
            //this.shield.ColorLerp(Color.Red, Color.Green, ((float)this.Health / Config.ShipHealth));

            //this.Weapon.Position = this.Position;
            laser.UpdateLaser(gameTime);

            if (isInvulnerable == true)
            {
                alpha += (float)gameTime.ElapsedGameTime.Milliseconds / 30;

                this.Sprite.ColorLerp(new Color(255, 255, 255, 255), new Color(0, 0, 0, 0), (alpha % 1));
            }

            if (this.Shield != null)
            {
                if (this.Shield.Health > 0 && this.Shield.Dead == true)
                {
                    //Config.ShieldHealth = this.Shield.Health;
                    int currentShieldHealth = this.Shield.Health;
                    Shield = new PlayerShield(Config.ShipShield, this);
                    Shield.Health = currentShieldHealth;
                }
            }

            //if (Config.Score > 10000 && purple == false)
            //{
            //    Config.CurrentProjectile = Config.BulletSheetEnergyPurple;
            //    purple = true;
            //}

            //if (Config.Score > 30000 && blue == false)
            //{
            //    Config.CurrentProjectile = Config.BulletSheetBlueLaserDouble;
            //    blue = true;
            //}

            /////////////AI
            if (Config.AIControlled)
                UpdateAI(gameTime);

            #region base.Update function
            //if (this.CollisionList != null)
            //{
            //    for (int i = this.CollisionList.Count - 1; i >= 0; i--)
            //    {
            //        if (this != CollisionList[i])
            //        {
            //            if (Node.CheckCollision(this, CollisionList[i]))
            //                this.Collide(this.CollisionList[i]);
            //        }
            //    }
            //}

            //if (this.CollisionList2 != null)
            //{
            //    for (int i = this.CollisionList2.Count - 1; i >= 0; i--)
            //    {
            //        if (this != CollisionList2[i])
            //        {
            //            if (Node.CheckCollision(this, CollisionList2[i]))
            //                this.Collide(this.CollisionList2[i]);
            //        }

            //    }
            //}

            //Velocity = Direction * Speed * ((float)gameTime.ElapsedGameTime.TotalMilliseconds / 30);
            //Position += Velocity;

            //this.Sprite.Update(gameTime); 
            #endregion
            base.Update(gameTime);

            if (this.Position.X < this.Sprite.Origin.X)
                this.Position = new Vector2(this.Sprite.Origin.X, this.Position.Y);
            else if (this.Position.X > Config.WorldBoundsX - this.Sprite.Origin.X)
                this.Position = new Vector2(Config.WorldBoundsX - this.Sprite.Origin.X, this.Position.Y);

            if (this.Position.Y < this.Sprite.Origin.Y)
                this.Position = new Vector2(this.Position.X, this.Sprite.Origin.Y);
            else if (this.Position.Y > Config.WorldBoundsY - this.Sprite.Origin.Y)
                this.Position = new Vector2(this.Position.X, Config.WorldBoundsY - this.Sprite.Origin.Y);

            ///////////AI

            ///////////////
            if (Config.ship1Active)
            {
                ParticleEffects.TriggerShip1Trail(this.Position);
            }
            else if (Config.ship2Active)
            {
                ParticleEffects.TriggerShip2Trail(this.Position);
            }
            else if (Config.ship3Active)
            {
                ParticleEffects.TriggerShip3Trail(this.Position);
            }

            if (this.ProjectileSpeedBar != null)
                this.ProjectileSpeedBar.Percent -= (float)(gameTime.ElapsedGameTime.TotalSeconds / 15);

            if (this.AddProjectileBar != null)
                this.AddProjectileBar.Percent -= (float)(gameTime.ElapsedGameTime.TotalSeconds / 15);

            if (this.HomingMissileBar != null)
                this.HomingMissileBar.Percent -= (float)(gameTime.ElapsedGameTime.TotalSeconds / 5);

            if (this.InvulnAbilityBar != null)
                this.InvulnAbilityBar.Percent -= (float)(gameTime.ElapsedGameTime.TotalSeconds / 10);

            //if (this.HealthBar != null)
            //    this.HealthBar.Percent = ((float)this.Health / Config.ShipHealth); 

            //if (this.ShieldBar != null)
            //    this.ShieldBar.Percent = ((float)Shield.Health / Config.ShieldHealth);
        }