Exemplo n.º 1
0
        public Inventory(World world)
        {
            _inventoryOverlay = world.EntitySystem.CreateEntity(true);
            _inventoryOverlay.AddComponent(new WorldUiOverlayEntityComponent(_inventoryOverlay, 512, 512));
            _inventoryOverlay.Position = new Vector3(-1.0f, 0.0f, -5.0f);

            _inventoryOverlay.IsActive = false;
        }
Exemplo n.º 2
0
 public Map(World world, string id)
 {
     _world = world;
     _id = id;
     _allMapEntities = new List<Entity>();
     var gameMode = GameInstance.GetService<GameModeManager>().ActiveGameMode;
     _dataPath = gameMode.GetMapFilePath(_id);
 }
Exemplo n.º 3
0
        public void OnOpening(object enterInformation)
        {
            if (!_isLoaded)
            {
                ActiveWorld = enterInformation as World;
                if (ActiveWorld == null) throw new InvalidOperationException("Did not receive loaded data.");

                _renderStatisticsOverlay = new UiOverlay();
                _renderStatisticsOverlay.AddElement(new RenderStatisticsView(ActiveWorld));

                GameInstance.LoadedSave = TestMock.CreateTempSave();
                GameInstance.LoadedSave.Load(GameInstance.GetService<GameModeManager>().ActiveGameMode);

                _isLoaded = true;
            }

            _inputSystem = GameInstance.GetService<InputSystem>();
            _screenManager = GameInstance.GetService<ScreenManager>();
            _sceneRenderer = GameInstance.GetService<SceneRenderer>();
            _collisionManager = GameInstance.GetService<CollisionManager>();
            _spriteBatch = GameInstance.GetService<SpriteBatch>();
            _shapeRenderer = GameInstance.GetService<ShapeRenderer>();
        }
Exemplo n.º 4
0
        public Player(World world)
        {
            var playerEntity = world.EntitySystem.CreateEntity(true);
            var collisionSize = new Vector3(0.35f, 0.6f, 0.35f);
            var collisionOffset = new Vector3(0.0f, 0.3f, 0.0f);
            var mesh = new Mesh(GameInstance.GraphicsDevice, Primitives.GenerateQuadForYBillboard());
            var diffuseTexture = GameInstance.Content.Load<Texture2D>(ResourceNames.Textures.DefaultGuy);
            var material = new Material
            {
                DiffuseTexture = diffuseTexture,
                UseTransparency = true,
                TexcoordScale = diffuseTexture.GetTexcoordsFromPixelCoords(32, 32),
                IsUnlit = true
            };
            
            playerEntity.AddComponent(new ModelEntityComponent(playerEntity, mesh, material, true));
            playerEntity.AddComponent(new FigureMovementAnimationComponent(playerEntity, diffuseTexture));
            playerEntity.AddComponent(new CollisionEntityComponent(playerEntity, collisionSize, collisionOffset, "Player", true));
            playerEntity.Position = new Vector3(5, 0, 8);

            var cameraEntity = world.EntitySystem.CreateEntity(true);
            cameraEntity.SetParent(playerEntity);
            _controllerComponent = cameraEntity.AddComponent(new PlayerControllerComponent(cameraEntity));
            var cameraComponent = cameraEntity.AddComponent(new CameraEntityComponent(cameraEntity, new Skybox(GameInstance)
            {
                Scale = 50,
                Texture = GameInstance.Content.Load<Texture2D>(ResourceNames.Textures.skybox_texture)
            }));
            cameraComponent.FarClipDistance = 50.0f;
            Camera = cameraComponent.Camera;

            var overlayCamera = cameraEntity.AddComponent(new CameraEntityComponent(cameraEntity, null, CameraMasks.UiOverlays));
            overlayCamera.Camera.FarClipDistance = 100.0f;
            overlayCamera.Camera.ClearColor = null;
            overlayCamera.Camera.DepthClear = 1.0f;
            overlayCamera.Camera.DepthStencilState = DepthStencilState.Default;
        }
Exemplo n.º 5
0
 public RenderStatisticsView(World activeWorld)
 {
     _world = activeWorld;
     _shapeRenderer = GameInstance.GetService<ShapeRenderer>();
     _debugSpriteFont = GameInstance.Content.Load<SpriteFont>(ResourceNames.Fonts.DebugFont);
 }