Esempio n. 1
0
        public EditorBase(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            // Get services from the global service container.
            var services = (ServiceContainer)ServiceLocator.Current;
            UIContentManager = services.GetInstance<ContentManager>("UIContent");
            InputService = services.GetInstance<IInputService>();
            AnimationService = services.GetInstance<IAnimationService>();
            GraphicsService = services.GetInstance<IGraphicsService>();
            GameObjectService = services.GetInstance<IGameObjectService>();
            UIService = services.GetInstance<IUIService>();

            // Create a local service container which can be modified in samples:
            // The local service container is a child container, i.e. it inherits the
            // services of the global service container. Samples can add new services
            // or override existing entries without affecting the global services container
            // or other samples.
            Services = services.CreateChildContainer();

            // Load a UI theme, which defines the appearance and default values of UI controls.
            Theme theme = UIContentManager.Load<Theme>("BlendBlue/Theme");

            FigureRenderer = new FigureRenderer(GraphicsService, 2000);
            DebugRenderer = new DebugRenderer(GraphicsService, UIContentManager.Load<SpriteFont>("BlendBlue/Default"));
            UIRenderer = new UIRenderer(GraphicsService.GraphicsDevice, theme);

            UIScreen = new UIScreen("Main Screen", UIRenderer)
            {
                Background = Color.TransparentBlack,
            };

            UIService.Screens.Add(UIScreen);

            Scene = new Scene();
        }
 public TestEntity(IGameObjectService gameObjectService, bool isGameObject)
 {
     if (isGameObject)
     {
         gameObjectService.AddEntity(this);
     }
 }
Esempio n. 3
0
        protected Sample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            // Get services from the global service container.
            var services = (ServiceContainer)ServiceLocator.Current;

            SampleFramework       = services.GetInstance <SampleFramework>();
            ContentManager        = services.GetInstance <ContentManager>();
            UIContentManager      = services.GetInstance <ContentManager>("UIContent");
            InputService          = services.GetInstance <IInputService>();
            AnimationService      = services.GetInstance <IAnimationService>();
            Simulation            = services.GetInstance <Simulation>();
            ParticleSystemService = services.GetInstance <IParticleSystemService>();
            GraphicsService       = services.GetInstance <IGraphicsService>();
            GameObjectService     = services.GetInstance <IGameObjectService>();
            UIService             = services.GetInstance <IUIService>();

            // Create a local service container which can be modified in samples:
            // The local service container is a child container, i.e. it inherits the
            // services of the global service container. Samples can add new services
            // or override existing entries without affecting the global services container
            // or other samples.
            Services = services.CreateChildContainer();

            // Store a copy of the original graphics screens.
            _originalGraphicsScreens = GraphicsService.Screens.ToArray();

            // Mouse is visible by default.
            SampleFramework.IsMouseVisible = true;
        }
Esempio n. 4
0
        protected Sample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            // Get services from the global service container.
              var services = (ServiceContainer)ServiceLocator.Current;
              SampleFramework = services.GetInstance<SampleFramework>();
              ContentManager = services.GetInstance<ContentManager>();
              UIContentManager = services.GetInstance<ContentManager>("UIContent");
              InputService = services.GetInstance<IInputService>();
              AnimationService = services.GetInstance<IAnimationService>();
              Simulation = services.GetInstance<Simulation>();
              ParticleSystemService = services.GetInstance<IParticleSystemService>();
              GraphicsService = services.GetInstance<IGraphicsService>();
              GameObjectService = services.GetInstance<IGameObjectService>();
              UIService = services.GetInstance<IUIService>();

              // Create a local service container which can be modified in samples:
              // The local service container is a child container, i.e. it inherits the
              // services of the global service container. Samples can add new services
              // or override existing entries without affecting the global services container
              // or other samples.
              Services = services.CreateChildContainer();

              // Store a copy of the original graphics screens.
              _originalGraphicsScreens = GraphicsService.Screens.ToArray();

              // Mouse is visible by default.
              SampleFramework.IsMouseVisible = true;
        }
Esempio n. 5
0
        protected Sample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            // Enable mouse centering and hide mouse by default.
            EnableMouseCentering = true;

            // Get services from the global service container.
            var services = (ServiceContainer)ServiceLocator.Current;

            ContentManager        = services.GetInstance <ContentManager>();
            UIContentManager      = services.GetInstance <ContentManager>("UIContent");
            InputService          = services.GetInstance <IInputService>();
            AnimationService      = services.GetInstance <IAnimationService>();
            Simulation            = services.GetInstance <Simulation>();
            ParticleSystemService = services.GetInstance <IParticleSystemService>();
            GraphicsService       = services.GetInstance <IGraphicsService>();
            GameObjectService     = services.GetInstance <IGameObjectService>();
            UIService             = services.GetInstance <IUIService>();

            // Create a local service container which can be modified in samples:
            // The local service container is a child container, i.e. it inherits the
            // services of the global service container. Samples can add new services
            // or override existing entries without affecting the global services container
            // or other samples.
            Services = services.CreateChildContainer();
        }
Esempio n. 6
0
    public ExplosionObject(IServiceLocator services)
    {
      Name = "Explosion";

      _inputService = services.GetInstance<IInputService>();
      _simulation = services.GetInstance<Simulation>();
      _gameObjectService = services.GetInstance<IGameObjectService>();
    }
Esempio n. 7
0
    public GrabObject(IServiceLocator services)
    {
      Name = "Grab";

      _inputService = services.GetInstance<IInputService>();
      _simulation = services.GetInstance<Simulation>();
      _gameObjectService = services.GetInstance<IGameObjectService>();
    }
Esempio n. 8
0
        public BallShooterObject(IServiceLocator services)
        {
            Name  = "BallShooter";
            Speed = 100;

            _inputService      = services.GetInstance <IInputService>();
            _simulation        = services.GetInstance <Simulation>();
            _gameObjectService = services.GetInstance <IGameObjectService>();
        }
Esempio n. 9
0
        public MyGameComponent(Microsoft.Xna.Framework.Game game, IServiceLocator services)
            : base(game)
        {
            // Get the services that this component needs regularly.
            _services          = services;
            _inputService      = services.GetInstance <IInputService>();
            _simulation        = services.GetInstance <Simulation>();
            _graphicsService   = services.GetInstance <IGraphicsService>();
            _gameObjectService = services.GetInstance <IGameObjectService>();
            _uiService         = services.GetInstance <IUIService>();

            // Add gravity and damping to the physics simulation.
            _simulation.ForceEffects.Add(new Gravity());
            _simulation.ForceEffects.Add(new Damping());

            // Create the DeferredGraphicsScreen and some 3D objects.
            _deferredGraphicsScreen             = new DeferredGraphicsScreen(services);
            _deferredGraphicsScreen.DrawReticle = true;
            _graphicsService.Screens.Insert(0, _deferredGraphicsScreen);

            // The GameObjects below expect try to retrieve DebugRenderer and Scene via
            // service container.
            var serviceContainer = (ServiceContainer)services;

            serviceContainer.Register(typeof(DebugRenderer), null, _deferredGraphicsScreen.DebugRenderer);
            serviceContainer.Register(typeof(IScene), null, _deferredGraphicsScreen.Scene);

            _cameraGameObject = new CameraObject(services);
            _gameObjectService.Objects.Add(_cameraGameObject);
            _deferredGraphicsScreen.ActiveCameraNode = _cameraGameObject.CameraNode;
            _gameObjectService.Objects.Add(new GrabObject(services));
            _gameObjectService.Objects.Add(new StaticSkyObject(services));
            _gameObjectService.Objects.Add(new GroundObject(services));
            for (int i = 0; i < 10; i++)
            {
                _gameObjectService.Objects.Add(new DynamicObject(services, 1));
            }

            // Get the "SampleUI" screen that was created by the StartScreenComponent.
            _uiScreen = _uiService.Screens["SampleUI"];

            // Add a second GraphicsScreen. This time it is a DelegateGraphicsScreen that
            // draws the UI over DeferredGraphicsScreen.
            _delegateGraphicsScreen = new DelegateGraphicsScreen(_graphicsService)
            {
                RenderCallback = context => _uiScreen.Draw(context.DeltaTime)
            };
            _graphicsService.Screens.Insert(1, _delegateGraphicsScreen);

            // Create the game menu window. But do not display it yet.
            _gameMenuWindow = new GameMenuWindow
            {
                // If the menu is opened and closed a lot, it is more efficient when _gameMenuWindow.Close()
                // makes the window invisible but does not remove it from the screen.
                HideOnClose = true,
            };
        }
Esempio n. 10
0
    public BallShooterObject(IServiceLocator services)
    {
      Name = "BallShooter";
      Speed = 100;

      _inputService = services.GetInstance<IInputService>();
      _simulation = services.GetInstance<Simulation>();
      _gameObjectService = services.GetInstance<IGameObjectService>();
    }
Esempio n. 11
0
    public RectangleObject(IServiceLocator services)
    {
      _inputService = services.GetInstance<IInputService>();
      _gameObjectService = services.GetInstance<IGameObjectService>();
      _debugRenderer = services.GetInstance<DebugRenderer>("DebugRenderer2D");

      _left = RandomHelper.Random.NextInteger(0, 1000);
      _top = RandomHelper.Random.NextInteger(0, 600);
      SetRandomColor();
    }
Esempio n. 12
0
        public RectangleObject(IServiceLocator services)
        {
            _inputService      = services.GetInstance <IInputService>();
            _gameObjectService = services.GetInstance <IGameObjectService>();
            _debugRenderer     = services.GetInstance <DebugRenderer>("DebugRenderer2D");

            _left = RandomHelper.Random.NextInteger(0, 1000);
            _top  = RandomHelper.Random.NextInteger(0, 600);
            SetRandomColor();
        }
        public EnvironmentDecalsControl(IServiceLocator services)
        {
            _gameObjectService = services.GetInstance <IGameObjectService>();

            Content = new TextBlock {
                Text = "Enable Decals"
            };
            var environmentDecalsObject = (EnvironmentDecalsObject)_gameObjectService.Objects["EnvironmentDecals"];

            IsChecked = environmentDecalsObject.IsEnabled;
        }
Esempio n. 14
0
    public MyGameComponent(Microsoft.Xna.Framework.Game game, IServiceLocator services)
      : base(game)
    {
      // Get the services that this component needs regularly.
      _services = services;
      _inputService = services.GetInstance<IInputService>();
      _simulation = services.GetInstance<Simulation>();
      _graphicsService = services.GetInstance<IGraphicsService>();
      _gameObjectService = services.GetInstance<IGameObjectService>();
      _uiService = services.GetInstance<IUIService>();

      // Add gravity and damping to the physics simulation.
      _simulation.ForceEffects.Add(new Gravity());
      _simulation.ForceEffects.Add(new Damping());

      // Create the DeferredGraphicsScreen and some 3D objects.
      _deferredGraphicsScreen = new DeferredGraphicsScreen(services);
      _deferredGraphicsScreen.DrawReticle = true;
      _graphicsService.Screens.Insert(0, _deferredGraphicsScreen);

      // The GameObjects below expect try to retrieve DebugRenderer and Scene via
      // service container.
      var serviceContainer = (ServiceContainer)services;
      serviceContainer.Register(typeof(DebugRenderer), null, _deferredGraphicsScreen.DebugRenderer);
      serviceContainer.Register(typeof(IScene), null, _deferredGraphicsScreen.Scene);

      _cameraGameObject = new CameraObject(services);
      _gameObjectService.Objects.Add(_cameraGameObject);
      _deferredGraphicsScreen.ActiveCameraNode = _cameraGameObject.CameraNode;
      _gameObjectService.Objects.Add(new GrabObject(services));
      _gameObjectService.Objects.Add(new StaticSkyObject(services));
      _gameObjectService.Objects.Add(new GroundObject(services));
      for (int i = 0; i < 10; i++)
        _gameObjectService.Objects.Add(new DynamicObject(services, 1));

      // Get the "SampleUI" screen that was created by the StartScreenComponent.
      _uiScreen = _uiService.Screens["SampleUI"];

      // Add a second GraphicsScreen. This time it is a DelegateGraphicsScreen that
      // draws the UI over DeferredGraphicsScreen.
      _delegateGraphicsScreen = new DelegateGraphicsScreen(_graphicsService)
      {
        RenderCallback = context => _uiScreen.Draw(context.DeltaTime)
      };
      _graphicsService.Screens.Insert(1, _delegateGraphicsScreen);

      // Create the game menu window. But do not display it yet.
      _gameMenuWindow = new GameMenuWindow
      {
        // If the menu is opened and closed a lot, it is more efficient when _gameMenuWindow.Close()
        // makes the window invisible but does not remove it from the screen.
        HideOnClose = true,
      };
    }
Esempio n. 15
0
        public CampfireControl(IServiceLocator services)
        {
            _gameObjectService = services.GetInstance <IGameObjectService>();

            var campfireObject = (CampfireObject)_gameObjectService.Objects["Campfire"];

            Content = new TextBlock {
                Text = "Enable Campfire Particle System"
            };
            IsChecked = campfireObject.IsEnabled;
        }
Esempio n. 16
0
 public CharStatsService(
     IStealthClient client,
     IGameObjectService gameObjectService,
     IObjectSearchService objectSearchService,
     IMoveItemService moveItemService)
     : base(client)
 {
     _gameObjectService   = gameObjectService;
     _objectSearchService = objectSearchService;
     _moveItemService     = moveItemService;
 }
Esempio n. 17
0
        public HelpComponent(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            var services = ServiceLocator.Current;

            _inputService      = services.GetInstance <IInputService>();
            _graphicsService   = services.GetInstance <IGraphicsService>();
            _gameObjectService = services.GetInstance <IGameObjectService>();

            // Add a new graphics screen to the graphics service.
            _graphicsScreen = new SampleGraphicsScreen(services);
            _graphicsService.Screens.Add(_graphicsScreen);

            game.Components.ComponentAdded += OnGameComponentAdded;
        }
Esempio n. 18
0
        //--------------------------------------------------------------
        #region Creation & Cleanup
        //--------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="SampleFramework" /> class.
        /// </summary>
        /// <param name="game">The XNA game.</param>
        /// <param name="initialSample">The type of the first sample.</param>
        public SampleFramework(SampleGame game, Type initialSample)
        {
            _game          = game;
            _initialSample = initialSample;

            // Get all required services.
            _services          = (ServiceContainer)ServiceLocator.Current;
            _inputService      = ServiceLocator.Current.GetInstance <IInputService>();
            _graphicsService   = _services.GetInstance <IGraphicsService>();
            _gameObjectService = _services.GetInstance <IGameObjectService>();

            InitializeSamples();
            InitializeController();
            InitializeMouse();
            InitializeProfiler();
            InitializeGui();
        }
Esempio n. 19
0
        public void Update()
        {
            if (Parent.Scene.ServiceProvider.GetService <ITimeService>().TimeScale == 0)
            {
                return;
            }

            if (Parent.GetComponent <OwnerComponent>().Owner != 0)
            {
                return;
            }

            if (!Parent.GetComponent <SelectComponent>().Selected)
            {
                ClearBuyButtons();
                return;
            }

            IGameObjectService gameObjectService = Parent.Scene.ServiceProvider.GetService <IGameObjectService>();

            foreach (var entity in gameObjectService.GetEntities())
            {
                if (!entity.HasComponent <BuyArmyComponent>())
                {
                    continue;
                }

                // return if other entity with BuyArmyComponent is selected
                if (entity != Parent && entity.GetComponent <SelectComponent>().Selected)
                {
                    ClearBuyButtons();
                    return;
                }
            }

            CreateBuyButtons();
        }
Esempio n. 20
0
        public EditorBase(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            // Get services from the global service container.
            var services = (ServiceContainer)ServiceLocator.Current;

            UIContentManager  = services.GetInstance <ContentManager>("UIContent");
            InputService      = services.GetInstance <IInputService>();
            AnimationService  = services.GetInstance <IAnimationService>();
            GraphicsService   = services.GetInstance <IGraphicsService>();
            GameObjectService = services.GetInstance <IGameObjectService>();
            UIService         = services.GetInstance <IUIService>();

            // Create a local service container which can be modified in samples:
            // The local service container is a child container, i.e. it inherits the
            // services of the global service container. Samples can add new services
            // or override existing entries without affecting the global services container
            // or other samples.
            Services = services.CreateChildContainer();

            // Load a UI theme, which defines the appearance and default values of UI controls.
            Theme theme = UIContentManager.Load <Theme>("BlendBlue/Theme");

            FigureRenderer = new FigureRenderer(GraphicsService, 2000);
            DebugRenderer  = new DebugRenderer(GraphicsService, UIContentManager.Load <SpriteFont>("BlendBlue/Default"));
            UIRenderer     = new UIRenderer(GraphicsService.GraphicsDevice, theme);

            UIScreen = new UIScreen("Main Screen", UIRenderer)
            {
                Background = Color.TransparentBlack,
            };

            UIService.Screens.Add(UIScreen);

            Scene = new Scene();
        }
Esempio n. 21
0
    //--------------------------------------------------------------
    #region Creation & Cleanup
    //--------------------------------------------------------------

    /// <summary>
    /// Initializes a new instance of the <see cref="SampleFramework" /> class.
    /// </summary>
    /// <param name="game">The XNA game.</param>
    /// <param name="initialSample">The type of the first sample.</param>
    public SampleFramework(SampleGame game, Type initialSample)
    {
      _game = game;
      _initialSample = initialSample;

      // Get all required services.
      _services = (ServiceContainer)ServiceLocator.Current;
      _inputService = ServiceLocator.Current.GetInstance<IInputService>();
      _graphicsService = _services.GetInstance<IGraphicsService>();
      _gameObjectService = _services.GetInstance<IGameObjectService>();

      InitializeSamples();
      InitializeController();
      InitializeMouse();
      InitializeProfiler();
      InitializeGui();
    }
Esempio n. 22
0
 public ObjectCreatorObject(IServiceLocator services)
 {
     _services          = services;
     _inputService      = services.GetInstance <IInputService>();
     _gameObjectService = services.GetInstance <IGameObjectService>();
 }
Esempio n. 23
0
 public AttackService(IStealthClient client, ICharStatsService charStatsService, IGameObjectService gameObjectService)
     : base(client)
 {
     _charStatsService  = charStatsService;
     _gameObjectService = gameObjectService;
 }
Esempio n. 24
0
 public ObjectCreatorObject(IServiceLocator services)
 {
   _services = services;
   _inputService = services.GetInstance<IInputService>();
   _gameObjectService = services.GetInstance<IGameObjectService>();
 }