public void Update(double deltaTime)
 {
     foreach (Projectile p in projectiles)
     {
         p.Update(deltaTime);
         if (p.TargetHit())
         {
             if (p is FrostOrb)
             {
                 OnHitEffect(hitFrostParticleEngine, p.GetPosition(), 15, 1.0f, 40, Color.White, Color.CornflowerBlue, Color.Aqua);
                 foreach (Creep c in creepManager.creepWave)
                 {
                     if (Vector2.Distance(p.GetPosition(), c.GetPosition()) <= p.GetRadius())
                     {
                         c.SetSlowedTimer    = p.GetSlowedTimer();
                         c.SetSlowedModifier = p.GetSlowedModifier();
                         c.TakeDamage(p.GetDamage());
                     }
                 }
             }
             else if (p is CannonBall)
             {
                 OnHitEffect(hitCannonParticleEngine, p.GetPosition(), 5, 0.5f, 0, Color.White, Color.White, Color.White);
             }
         }
     }
     projectiles.RemoveAll(x => x.TargetHit());
     hitFrostParticleEngine.Update();
     hitCannonParticleEngine.Update();
 }
예제 #2
0
        public void Update(double deltaTime)
        {
            mouseState = Mouse.GetState();
            projectileManager.Update(deltaTime);
            userInterface.Update();
            particleEngine.Update();
            TowerAttack(deltaTime);

            if (mouseState.LeftButton == ButtonState.Pressed && userInterface.canPlaceCannonTower == true)
            {
                DrawRenderTargetLayer(graphics);
                CannonTower t = new CannonTower(TextureManager.towerTexture, new Vector2(mouseState.X, mouseState.Y));
                if (CanPlace(t) && UserInterface.gold >= t.Cost())
                {
                    userInterface.canPlaceCannonTower = false;
                    towers.Add(t);
                    UserInterface.gold -= t.Cost();
                }
            }
            if (mouseState.LeftButton == ButtonState.Pressed && userInterface.canPlaceMagicTower == true)
            {
                DrawRenderTargetLayer(graphics);
                MagicTower t = new MagicTower(TextureManager.towerTexture, new Vector2(mouseState.X, mouseState.Y));
                if (CanPlace(t) && UserInterface.gold >= t.Cost())
                {
                    userInterface.canPlaceMagicTower = false;
                    towers.Add(t);
                    UserInterface.gold -= t.Cost();
                }
            }
        }