コード例 #1
0
        public override void Update(GameTime gameTime, GameState state)
        {
            // update component positions for menu hiding
            if (_isMenuHidden && _position.Y < _graphicsDevice.Viewport.Height)
            {
                // apply adjustments to position
                var orig_pos = new Vector2(_position.X, _position.Y);
                _position = new Vector2(0, _position.Y + 50);

                // check for completion
                if (_position.Y > _graphicsDevice.Viewport.Height)
                {
                    _position = new Vector2(0, _graphicsDevice.Viewport.Height);
                }

                #region UPDATE OTHER COMPONENTS
                var diff = orig_pos.Y - _position.Y;
                UpdateComponentPositions(diff);
                #endregion
            }
            else if (!_isMenuHidden && _position.Y > _startPosition.Y)
            {
                // apply adjustments to position
                var orig_pos = new Vector2(_position.X, _position.Y);
                _position = new Vector2(0, _position.Y - 50);

                // check for completion
                if (_position.Y < _startPosition.Y)
                {
                    _position         = _startPosition;
                    _isMenuDisplaying = true;
                }

                #region UPDATE OTHER COMPONENTS
                var diff = orig_pos.Y - _position.Y;
                UpdateComponentPositions(diff);
                #endregion
            }

            // update components
            _closeMenuButton.Update(gameTime, state);
            // only update below components if menu is not hidden
            if (!_isMenuHidden)
            {
                foreach (Component c in _components)
                {
                    c.Update(gameTime, state);
                }
                Btn_SelectHouses.Update(gameTime, state);
                Btn_SelectReso.Update(gameTime, state);
                Btn_SelectDeco.Update(gameTime, state);

                var list = SelectionCells_BldgHouses_Btns;
                switch (SelectionCells_ViewIndex)
                {
                case 801:
                    list = SelectionCells_BldgReso_Btns;
                    break;

                case 802:
                    list = SelectionCells_BldgDeco_Btns;
                    break;

                default:
                    list = SelectionCells_BldgHouses_Btns;
                    break;
                }

                foreach (var e in list)
                {
                    e.Update(gameTime, state);
                }

                //DeleteBuildingBtn.Update(gameTime, state);
            }

            // save gamestate
            State = state;
        }