예제 #1
0
        public virtual void Update(GameTime gameTime)
        {
            if (stunned)
            {
                stunAnimation.Update(gameTime);
                unstunTime -= (float)gameTime.ElapsedGameTime.TotalSeconds;

                if (unstunTime <= 0)
                {
                    stunned = false;
                    stunAnimation = null;
                }
            }

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

            //Only try to attack if the tower has a damage value of greater than 0
            if (Damage > 0 && AttackCharge >= AttackSpeed)
            {
                Attack(gameTime);
            }

            foreach (Projectile p in Projectiles)
            {
                if(p.Enabled)
                    p.Update(gameTime);
            }

            if (DisabledProjectiles.Count > 0)
            {
                foreach (Projectile p in DisabledProjectiles)
                {
                    Projectiles.Remove(p);
                }
            }

            if (explodeAnimation != null)
            {
                explodeAnimation.Update(gameTime);
            }
        }
예제 #2
0
 // Finally, remove the tower from the list, ensuring it will be garbage collected.
 public void FinishExploding()
 {
     Console.WriteLine("Explosion callback completed.");
     explodeAnimation = null;
     Destroyed = true;
 }
예제 #3
0
 public void Stun(float duration)
 {
     stunned = true;
     unstunTime = duration;
     stunAnimation = new Animation(new int[] { 46, 47 }, 5);
 }
        public void UpdateTowerDestruction(GameTime gameTime)
        {
            // Set the animation properties here.
            destructionWaveWidth += ((TileEngine.TileWidth * 2) / towerDestroyInterval) * (float)gameTime.ElapsedGameTime.TotalSeconds;
            destructionWaveHeight += ((TileEngine.TileHeight * 2) / towerDestroyInterval) * (float)gameTime.ElapsedGameTime.TotalSeconds;

            // Change the color
            destructionWaveColor = new Color(.5f, .5f, .5f, .2f);

            if (currentGameTime.TotalGameTime.TotalSeconds >= nextTowerDestroyTime)
            {
                DestroyTowers(GetTowersAtDistance(destroyTowerDistance));
                destroyTowerDistance++;

                nextTowerDestroyTime = (float)currentGameTime.TotalGameTime.TotalSeconds + towerDestroyInterval;

                if (builtTowers.Count == 0)
                {
                    destroyTowersAnimation = null;
                    destroyingTowers = false;
                    Weaknesses = new float[] { 0f, 0f, 0f, 0f, 0f };
                }
            }
        }
예제 #5
0
 // Creates the explosion animation and triggers the countdown to absolute destruction.
 public void Explode()
 {
     explodeAnimation = new Animation(new int[] { 48, 49, 50, 51, 52, 53 }, 12, true);
     explodeAnimation.AnimationFinish += new AnimationFinishEventHandler(FinishExploding);
     AudioManager.PlaySoundEffect(10);
 }
        public void UpdateAttack(GameTime gameTime)
        {
            // Here, update the various forms of attack Hamilton uses.  Shoot a beam at a random tower and BOOM it!
            if (bossPhase == BossPhase.AttackWalk && beamAnimation == null && nextBeamTime <= gameTime.TotalGameTime.TotalSeconds)
            {
                // Fire a beam
                FireBeam();
            }

            if (shieldActive)
            {
                if (gameTime.TotalGameTime.TotalSeconds > nextShieldTime)
                {
                    SetShieldImmunity();
                    nextShieldTime = (float)gameTime.TotalGameTime.TotalSeconds + shieldChangeCooldown;
                }
            }

            if (bossPhase == BossPhase.AttackWalk && orbAnimation == null && nextOrbTime <= gameTime.TotalGameTime.TotalSeconds)
            {
                // Shoot an orb
                FireOrb();
            }

            if (beamAnimation != null)
            {
                beamAnimation.Update(gameTime);

                beamElapsedTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
                // This becomes 1 once the extend time has completed.
                beamLength = (float)Math.Min((beamElapsedTime / beamExtendTime), 1);
                beamLength *= Vector2.Distance(Position, beamTarget.Position);

                if (beamElapsedTime > beamVisibleTime)
                {
                    beamAnimation = null;
                    beamElapsedTime = 0f;
                    nextBeamTime = (float)gameTime.TotalGameTime.TotalSeconds + beamCooldown;
                    BeamHit(beamTarget);
                }
            }

            if (orbAnimation != null)
            {
                float distanceThisFrame = (orbSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds);

                if (Vector2.Distance(orbTarget.Position, orbPosition) <= distanceThisFrame)
                {
                    OrbHit(orbTarget);
                }
                else
                {
                    Vector2 movement = orbTarget.Position - orbPosition;
                    movement.Normalize();
                    movement *= distanceThisFrame;
                    orbPosition += movement;
                }
            }
        }
        public void StartFinalPhase()
        {
            AudioManager.PlaySong(5);
            Weaknesses = new float[] { 0f, 0f, 0f, 0f, 0f };
            isBurning = false;
            isPoisoned = false;
            isFrozen = false;

            beamAnimation = null;
            orbAnimation = null;

            // Here Hamilton will mock the player.

            // He then destroys towers in a ring outward from wherever he respawns.

            builtTowers = new List<Tower>(GameScene.Towers.Where(x => x.Constructed));
            destroyTowersAnimation = new Animation(new int[] { 45 }, 0);

            destroyingTowers = true;

            stunned = true;
            unstunTime = (float)currentGameTime.TotalGameTime.TotalSeconds + 15f;
            GameScene.GUI.countdownActive = true;
            GameScene.GUI.countdownTime = 15f;
        }
        public void OrbHit(Tower target)
        {
            AudioManager.PlaySoundEffect(16, .5f);

            orbAnimation = null;

            List<Tower> affectedTowers = GameScene.Towers.FindAll(x => x.Name == target.Name);
            foreach (Tower t in affectedTowers)
            {
                t.Stun(stunDuration);
            }

            nextOrbTime = (float)currentGameTime.TotalGameTime.TotalSeconds + orbCooldown;
        }
        public void FireOrb()
        {
            AudioManager.PlaySoundEffect(15, .5f);
            List<Tower> viableTargets = GameScene.Towers.FindAll(x => Vector2.Distance(x.Position, Position) <= orbRange);
            if (viableTargets.Count <= 0)
            {

                nextOrbTime = (float)currentGameTime.TotalGameTime.TotalSeconds + 4f;
                return;
            }

            Random rand = new Random();

            // Create the orb
            orbAnimation = new Animation(new int[] { 45 }, 0);
            orbPosition = Position;
            orbTarget = viableTargets[rand.Next(0, viableTargets.Count)];
        }
        public void FireBeam()
        {
            AudioManager.PlaySoundEffect(13, .5f);
            List<Tower> validTargets = GameScene.Towers.FindAll(x => Vector2.Distance(Position, x.Position) <= beamRange);
            if (validTargets.Count <= 0)
                return;

            Random rand = new Random();

            beamTarget = validTargets[rand.Next(0, validTargets.Count)];
            beamAnimation = new Animation(new int[] { 42, 43, 44 });
        }