Exemplo n.º 1
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();
                }
            }
        }
        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();
                }
            }
        }