示例#1
0
        public void DrawShaded(SpriteBatch sb, GameTime gt, List <EnemyChar> enemies, List <BaseProjectile> projectiles, ContentManager content, EnemySpawnManager enemySpawnManager)
        {
            sb.Begin();
            m_menuBackground.DrawMe(sb);
            m_selectionBorder.DrawMe(sb);
            sb.DrawString(Game1.gameFontNorm, "Page: " + (m_page + 1) + "\nCount: " + m_towerOptions.Count, new Vector2(72, 972), Color.White, 0, Game1.gameFontNorm.MeasureString("Page: " + (m_page + 1) + "\nCount: " + m_towerOptions.Count) / 2, 1, SpriteEffects.None, 0);
            sb.End();

            m_menu.DrawMe(sb, gt);

            sb.Begin();
            sb.Draw(m_spawnBarTex, m_spawnBarPos, m_spawnBarSrc, Color.White);
            sb.DrawString(Game1.gameFontNorm, "Wave: " + enemySpawnManager.CurrentWave, new Vector2(1380, 875), Color.Black);
            sb.End();

            for (int i = 0; i < m_towerOptions.Count; i++)
            {
                if (i >= m_minIndex && i < m_maxIndex)
                {
                    m_towerOptions[i].DrawMe(sb, gt);
                    m_towerOptions[i].IsClickable = true;
#if DEBUG
                    sb.Begin();
                    sb.DrawString(Game1.debugFont, "Button: " + m_towerOptions[i].Tower.PartProps.Count, m_towerOptions[i].Position, Color.White);
                    sb.End();
#endif
                }
                else
                {
                    m_towerOptions[i].IsClickable = false;
                }
            }
        }
示例#2
0
        public void UpdateMe(InputManager input, List <Tower> savedTowers, ContentManager content, GameTime gt, List <EnemyChar> enemies, List <BaseProjectile> projectiles, PlayerStats userData, EnemySpawnManager enemySpawnManager)
        {
            // Update the freeform menu component
            m_menu.UpdateMe(input, userData);

            // Modify the width of the source rectangle according to the time left before spawning
            m_spawnBarSrc.Width = (int)(m_spawnBarTex.Width * (enemySpawnManager.CurrTime / enemySpawnManager.WaveTime));

            // Recreate new set of buttons if the number of saved towers have changed
            if (savedTowers.Count != m_numberOfTowers)
            {
                m_towerOptions   = new List <TowerButton>();
                m_numberOfTowers = savedTowers.Count;

                for (int i = 0; i < savedTowers.Count; i++)
                {
                    TowerButton button = new TowerButton(content.Load <Texture2D>("Art\\PlaceholderArt\\GameplayGUI\\TowerHighlight"), new Vector2(180 + (72 * (i - m_minIndex)), 1044), Color.White, 2, 1, 1, 1, content, new ToolTip(content.Load <Texture2D>("Art\\GameArt\\ToolTipBacking"), Game1.debugFont, new Vector2(0, 0), Color.White, Color.Black, Vector2.Zero, "" + savedTowers[i].TowerName + "\nHealth: " + savedTowers[i].Health + "\nCost: " + savedTowers[i].TowerCost), i, "");
                    button.Tower = new Tower(content, savedTowers[i], new Vector2(216 + (144 * (i - m_minIndex)), 1008));
                    button.Tower.UpdateAllProps();
                    button.Tower.UpdatePosition();
                    m_towerOptions.Add(button);
                }
            }

            // Page switching logic
            if (m_menu.Buttons[1].IsPressed)
            {
                m_page++;
            }
            if (m_menu.Buttons[2].IsPressed)
            {
                m_page--;
            }

            // Since each page contains 5 tower buttons
            m_maxPages = m_towerOptions.Count / 5;

            // Lock the number of pages
            LockPages();

            // Set the lowest display index and max display index
            m_minIndex = m_page * 5;
            m_maxIndex = m_minIndex + 5;

            for (int i = 0; i < m_towerOptions.Count; i++)
            {
                m_towerOptions[i].Position = new Vector2(216 + (144 * (i - m_minIndex)), 1008);
                m_towerOptions[i].UpdateMe(input, gt, enemies, projectiles, content);

                // Make sure there is a tower to display
                if (m_towerOptions[i].Tower == null)
                {
                    m_towerOptions[i].Tower = new Tower(content, savedTowers[i], m_towerOptions[i].Position);
                }

                if (i >= m_minIndex && i < m_maxIndex)
                {
                    m_towerOptions[i].IsClickable = true;
                }
                else
                {
                    m_towerOptions[i].IsClickable = false;
                }
            }
        }