Example #1
0
        public LevelScreen(LoderGame game, SystemManager systemManager, EntityManager entityManager)
            : base(game.screenSystem, ScreenType.Level)
        {
            _game = game;
            _systemManager = systemManager;
            _entityManager = entityManager;
            _levelSystem = (LevelSystem)_systemManager.getSystem(SystemType.Level);
            _content = new ContentManager(_game.Services);
            _content.RootDirectory = "Content";
            _equipmentSystem = (EquipmentSystem)_systemManager.getSystem(SystemType.Equipment);
            _playerId = PlayerSystem.PLAYER_ID;
            _pixel = new Texture2D(_game.GraphicsDevice, 1, 1);
            _pixel.SetData<Color>(new[] { Color.White });
            _arial = _content.Load<SpriteFont>("arial");
            _dialogePanes = new List<InteractiveDialoguePane>();
            _dialogueFont = _content.Load<SpriteFont>("shared_ui/dialogue_font");
            _dialogueOptionFont = _content.Load<SpriteFont>("shared_ui/dialogue_option_font");

            ToolbarComponent toolbarComponent = (ToolbarComponent)_entityManager.getComponent(LevelSystem.currentLevelUid, _playerId, ComponentType.Toolbar);

            _toolbarDisplay = new ToolbarDisplay(_game.spriteBatch, _equipmentSystem, toolbarComponent);
            _inventoryDisplay = new InventoryDisplay(_game.spriteBatch, _equipmentSystem, (InventoryComponent)_entityManager.getComponent(LevelSystem.currentLevelUid, _playerId, ComponentType.Inventory), toolbarComponent);
            _inventoryDisplay.inFocus = false;
            _toolbarDisplay.inFocus = true;

            _healthBar = new LargeHealthBar(_game.spriteBatch);
        }
Example #2
0
 public ToolbarDisplay(SpriteBatch spriteBatch, EquipmentSystem equipmentSystem, ToolbarComponent toolbarComponent)
 {
     _spriteBatch = spriteBatch;
     _toolbarComponent = toolbarComponent;
     _equipmentSystem = equipmentSystem;
     _pixel = new Texture2D(_spriteBatch.GraphicsDevice, 1, 1);
     _pixel.SetData<Color>(new[] { Color.White });
 }
Example #3
0
        public void PreSolve(Contact contact, ref Manifold manifold)
        {
            EventSystem eventSystem = (EventSystem)_systemManager.getSystem(SystemType.Event);
            Fixture     fixtureA    = contact.FixtureA;
            Fixture     fixtureB    = contact.FixtureB;
            int         playerId    = PlayerSystem.PLAYER_ID;
            int         entityA     = (int)fixtureA.Body.UserData;
            int         entityB     = (int)fixtureB.Body.UserData;
            string      levelUid    = LevelSystem.currentLevelUid;

            // Check for custom collision filters
            bool fixtureAIgnoresEntityB = fixtureA.IsIgnoredEntity(entityB);
            bool fixtureBIgnoresEntityA = fixtureB.IsIgnoredEntity(entityA);

            if (fixtureAIgnoresEntityB)
            {
                contact.Enabled = false;
            }
            else if (fixtureBIgnoresEntityA)
            {
                contact.Enabled = false;
            }

            // Check for item pickup
            if (contact.IsTouching() && (entityA == playerId || entityB == playerId))
            {
                int           itemEntityId  = entityA == playerId ? entityB : entityA;
                Fixture       fixture       = entityA == playerId ? fixtureB : fixtureA;
                ItemComponent itemComponent = _entityManager.getComponent(levelUid, itemEntityId, ComponentType.Item) as ItemComponent;

                if (itemComponent != null)
                {
                    contact.Enabled = false;
                    if (itemComponent.state.inWorld)
                    {
                        InventoryComponent playerInventory = _entityManager.getComponent(levelUid, playerId, ComponentType.Inventory) as InventoryComponent;
                        EquipmentSystem    equipmentSystem = _systemManager.getSystem(SystemType.Equipment) as EquipmentSystem;

                        equipmentSystem.addInventoryItem(playerInventory, itemComponent);
                        itemComponent.state.inWorld = false;
                        _bodiesToRemove.Add(fixture.Body);
                        _entityManager.killEntity(levelUid, itemEntityId);
                        eventSystem.postEvent(new GameEvent(GameEventType.OnItemPickedUp, itemEntityId));
                    }
                }
            }
        }
Example #4
0
 // startPersistentSystems -- Certain systems (such as WorldMap, Level, Player, etc...) that need to be active throughout the entire game
 public void startPersistentSystems()
 {
     _playerSystem = new PlayerSystem(_systemManager, _entityManager);
     _equipmentSystem = new EquipmentSystem(_systemManager, _entityManager);
     _levelSystem = new LevelSystem(this, _systemManager, _entityManager);
     _systemManager.add(_playerSystem, -1);
     _systemManager.add(_equipmentSystem, -1);
     _systemManager.add(_levelSystem, -1);
 }