Beispiel #1
0
        public override void Update(GameTime gameTime)
        {
            if (Helper.CurrentGameStatus == GameStatus.PLAYING)
            {
                PreviousPosition  = PixelPosition;
                OrbLight.Position = new Vector2(CentrePos.X, CentrePos.Y) - Camera.CamPos;

                switch (projectileState)
                {
                case PROJECTILE_STATUS.Idle:
                    this.Visible     = false;
                    OrbLight.Enabled = false;
                    break;

                case PROJECTILE_STATUS.Firing:
                    flyTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;

                    this.Visible        = true;
                    this.gotDirection   = false;
                    this.PixelPosition += (Direction * Velocity);
                    OrbLight.Enabled    = true;
                    OrbLight.Scale      = defaultScale;

                    FaceThis(gameTime);

                    CollisionCheck();

                    // Play sounds
                    if (!ShootSoundPlayed)
                    {
                        ShootSound.Play();
                        ShootSoundPlayed = true;
                    }
                    break;

                case PROJECTILE_STATUS.Exploding:
                    this.Visible     = false;
                    ShootSoundPlayed = false;

                    OrbLight.Scale = defaultScale * 2;

                    timer += (float)gameTime.ElapsedGameTime.TotalSeconds;

                    if (timer > explosionLifeSpan - explosionLifeSpan + 0.1f)
                    {
                        OrbLight.Enabled = false;
                    }

                    if (timer > explosionLifeSpan)
                    {
                        timer = 0f;
                        // Reload Projectile
                        projectileState = PROJECTILE_STATUS.Idle;
                    }
                    break;
                }
                base.Update(gameTime);
            }
        }
Beispiel #2
0
        private void CollisionCheck()
        {
            // Projectile is out of tile map bounds
            if (this.PixelPosition.X < 0 || this.PixelPosition.Y < 0 ||
                this.PixelPosition.X > Camera.WorldBound.X ||
                this.PixelPosition.Y > Camera.WorldBound.Y ||
                flyTimer > flyingLifeSpan)
            {
                flyTimer        = 0f;
                projectileState = PROJECTILE_STATUS.Exploding;
            }

            // Ensure the sentry doesn't shoot itself !
            if (Parent != "PLAYER")
            {
                Camera     thisCamera = (Camera)Game.Services.GetService(typeof(Camera));
                TilePlayer player     = (TilePlayer)Game.Services.GetService(typeof(TilePlayer));

                if (CollideWith(player))
                {
                    //playerDamageRate = damageRate.Next(5, 15);
                    flyTimer        = 0f;
                    projectileState = PROJECTILE_STATUS.Exploding;
                    player.Health  -= playerDamageRate;
                    thisCamera.Shake(7.5f, 0.25f);
                    InputEngine.ShakePad(0.75f, 1.0f, 1.0f);
                    _sndPierce.Play();
                }
            }
            else
            {
                // Reference Collision Objects
                List <SentryTurret> SentryTurretList = (List <SentryTurret>)Game.Services.GetService(typeof(List <SentryTurret>));

                // Check collision with Sentry
                foreach (SentryTurret otherSentry in SentryTurretList)
                {
                    if (CollideWith(otherSentry))
                    {
                        //sentryDamageRate = damageRate.Next(30, 40);
                        flyTimer            = 0f;
                        projectileState     = PROJECTILE_STATUS.Exploding;
                        otherSentry.Health -= sentryDamageRate;
                        _sndPierce.Play();
                    }
                }
            }
        }
Beispiel #3
0
 public void Shoot(Vector2 TargetDirection)
 {
     projectileState = PROJECTILE_STATUS.Firing;
     Target          = TargetDirection;
     isPastTarget    = false;
 }