コード例 #1
0
        public BackButtonGuiLayer()
        {
            _content = ContentManagerFactory.RequestContentManager();
            var buttonTexture = _content.Load <Texture2D>("DemoScreen/BackButton");
            var buttonSize    = new Rectangle(15, 15, 45, 45);

            _backButton = new ImageButton(buttonTexture, buttonSize);
        }
コード例 #2
0
        public override void LoadContent()
        {
            base.LoadContent();

            var graphicsDeviceService = (IGraphicsDeviceService)_serviceProvider.GetService(typeof(IGraphicsDeviceService));

            _content     = ContentManagerFactory.RequestContentManager();
            _spriteBatch = new SpriteBatch(graphicsDeviceService.GraphicsDevice);
            Font         = _content.Load <BitmapFont>("montserrat-32");
        }
コード例 #3
0
        internal static ICollectionSelector InitializeContentManager(TestContext testContext)
        {
            string                sourceFolder             = string.Empty;
            string                targetFolder             = string.Empty;
            bool                  reportsCreated           = false;
            List <string>         scenarioList             = null;
            string                runtimeResourcesSelector = null;
            List <BadCombination> badCombinations          = null;
            List <ReportWeight>   reportsWeight            = null;

            Logging.Log("Initialize Content for the test");

            // Get runtime parameters
            LoadContextProperty(testContext, SharedConstants.SourceReportFolderKey, ref sourceFolder);
            LoadContextProperty(testContext, SharedConstants.TargetReportFolderKey, ref targetFolder);
            LoadContextProperty(testContext, SharedConstants.ScenarioListKey, ref scenarioList);
            LoadContextProperty(testContext, SharedConstants.RuntimeResourcesSelectorKey, ref runtimeResourcesSelector);
            LoadContextProperty(testContext, SharedConstants.InitializedResourcesKey, ref reportsCreated);
            LoadContextProperty <List <BadCombination> >(testContext, SharedConstants.BadCombinationsKey, ref badCombinations);
            LoadContextProperty <List <ReportWeight> >(testContext, SharedConstants.ReportsWeightKey, ref reportsWeight);

            ICollectionSelector itemSelector = null;

            if (String.IsNullOrEmpty(runtimeResourcesSelector))
            {
                itemSelector = new RandomSelector();
            }
            else
            {
                if (runtimeResourcesSelector.Equals("random", StringComparison.InvariantCultureIgnoreCase))
                {
                    itemSelector = new RandomSelector();
                }
                else
                {
                    itemSelector = new SequentialSelector();
                }
            }

            foreach (string scenario in scenarioList)
            {
                IContentManager contentManager = ContentManagerFactory.GetInstance(scenario);
                contentManager.Initialize(scenario, scenario);
                contentManager.ItemSelector = itemSelector;
                contentManager.PopulateReportListFromServer();
                contentManager.BadReportMethodCombinations = badCombinations;
                contentManager.ReporstWeight = reportsWeight;
            }

            return(itemSelector);
        }
コード例 #4
0
        public OpenWorldGameMode(ViewportAdapter viewPort, IPossibleMovements possibleMovements, string worldName, EntityManager entityManager, StoryEngine storyEngine, EventHandler clickEvent) : base(clickEvent)
        {
            _entityManager      = entityManager;
            EntityRenderersDict = new Dictionary <Entity, AbstractEntityRenderer>();
            _possibleMovements  = possibleMovements;
            _content            = ContentManagerFactory.RequestContentManager();
            RenderList          = new List <IRenderable>();
            Map = _content.Load <TiledMap>($"TopDownRpg/{worldName}");
            var graphics = StaticServiceLocator.GetService <GraphicsDevice>();

            _mapRenderer = new FullMapRenderer(graphics);
            _mapRenderer.SwapMap(Map);
            _tileSize     = new Vector2(Map.TileWidth, Map.TileHeight);
            _moverManager = new MoverManager();
            var collisionSystem = new CompositeAbstractCollisionSystem(_possibleMovements);

            _expiringSpatialHash = new ExpiringSpatialHashCollisionSystem <Entity>(_possibleMovements);
            _spatialHashMover    = new SpatialHashMoverManager <Entity>(collisionSystem, _expiringSpatialHash);
            AddPlayer();
            var entityController = EntityControllerFactory.AddEntityController(PlayerEntity.Instance, _possibleMovements, _moverManager);
            var texture          = _content.Load <Texture2D>("TopDownRpg/Path");
            var endTexture       = _content.Load <Texture2D>("TopDownRpg/BluePathEnd");

            collisionSystem.AddCollisionSystem(new TiledCollisionSystem(_possibleMovements, Map, "Collision-Layer"));
            collisionSystem.AddCollisionSystem(_expiringSpatialHash);
            CollisionSystem = collisionSystem;
            AddClickController(PlayerEntity.Instance);
            PathRenderer = new PathRenderer(_moverManager, PlayerEntity.Instance, texture, endTexture, _tileSize.ToPoint(), Map.Width, Map.Height);
            UpdateList.Add(_expiringSpatialHash);
            UpdateList.Add(entityController);
            UpdateList.Add(_spatialHashMover);
            UpdateList.Add(_moverManager);
            CameraTracker = CameraTrackerFactory.CreateTracker(viewPort, EntityRenderersDict[PlayerEntity.Instance], Map);
            UpdateList.Add(CameraTracker);
            LoadEntities();
            var dialogFont = _content.Load <SpriteFont>("dialog");
            var settings   = StaticServiceLocator.GetService <IControllerSettings>();

            DialogBox = new EntityStoryBoxDialog(ScreenSize.Size, dialogFont, settings.GamePadEnabled);
            GuiManager.AddGuiLayer(DialogBox);
            storyEngine.LoadWorld(AddEntity, RemoveEntity, CollisionSystem.CheckMovementCollision, worldName);
            InteractEvent += (sender, args) =>
            {
                var facingDirection = PlayerEntity.Instance.FacingDirection;
                var interactTarget  = (PlayerEntity.Instance.Position + facingDirection).ToPoint();
                Interact(interactTarget);
            };
            AddInteractionController();
            CameraController.AddCameraZoomController(CameraTracker, ClickController);
            CameraController.AddCameraMovementController(CameraTracker, ClickController);
        }
コード例 #5
0
 public virtual void Play(string audioType, string fileName)
 {
     if (audioType.Equals("wav", StringComparison.OrdinalIgnoreCase))
     {
         try
         {
             System.Diagnostics.Debug.WriteLine("AudioPlayer::play(): " + fileName);
             _content  = ContentManagerFactory.RequestContentManager();
             _effect   = _content.Load <SoundEffect>(fileName);
             _instance = _effect.CreateInstance();
             _instance.Play();
         }
         catch (Exception e)
         {
             Debug.WriteLine(e);
         }
     }
     else
     {
         Debug.WriteLine("Invalid media. " + audioType + " format not supported");
     }
 }
コード例 #6
0
ファイル: GameFrameGame.cs プロジェクト: Taikatou/GameFrame
 protected override void LoadContent()
 {
     Content.RootDirectory = "Content";
     ContentManagerFactory.Initialise(Content);
 }
コード例 #7
0
ファイル: SongPlayer.cs プロジェクト: Taikatou/GameFrame
 public SongPlayer()
 {
     Content = ContentManagerFactory.RequestContentManager();
 }