Example #1
0
 public GameState(Game game)
 {
     Game = game;
     ActiveScripts = new List<GameEntityScript>();
     BlockingHandlers = new List<object>();
     Camera = new Camera2D();
     Player = new Player();
     Level = new Level();
     Inventory = new InventoryService();
     ReactionProgress = new ReactionProgressComponent();
 }
Example #2
0
        public override void Initialize()
        {
            _inventory = Game.Services.GetService<InventoryService>();
            _spriteBatch = Game.Services.GetService<SpriteBatch>();
            _gameState = Game.Services.GetService<GameState>();

            RenderPosition = new Point(Game.GraphicsDevice.Viewport.Width -
                _inventory.Slots.Count * (InventoryItemRenderSize.X + InventoryItemRenderMargin),
                InventoryItemRenderMargin);

            var renderingRectangles = new List<Rectangle>();
            for (int i = 0; i < _inventory.Slots.Count; i++ )
            {
                var rect = new Rectangle(Game.GraphicsDevice.Viewport.Width -
                    (_inventory.Slots.Count- i) * (InventoryItemRenderSize.X + InventoryItemRenderMargin),
                    InventoryItemRenderMargin, InventoryItemRenderSize.X, InventoryItemRenderSize.Y);
                renderingRectangles.Add(rect);
                if (_inventory.Slots[i] != null)
                {
                    _inventory.Slots[i].Initialize(Game, rect);
                }
            }

            _renderingRectangles = renderingRectangles.ToArray();

            _itemCountFont = Game.Content.Load<SpriteFont>(@"Fonts\MenuFont");

            base.Initialize();
        }