Exemplo n.º 1
0
 /// <summary>Initializes a new instance of the UnityGameFactory class</summary>
 /// <param name="resources">Resource library</param>
 /// <param name="worldFactory">World factory</param>
 /// <param name="inputManager">Input manager</param>
 public UnityGameFactory(
     IResourceLibrary resources,
     IWorldFactory worldFactory,
     IInputManager inputManager)
     : base(resources, worldFactory, inputManager)
 {
 }
Exemplo n.º 2
0
        public MenuWorld(ISkin skin, IWorldFactory worldFactory, IAssetManagerProvider assetManagerProvider, I2DRenderUtilities twodRenderUtilities)
        {
            this.m_2DRenderUtilities = twodRenderUtilities;

            this.m_LogoTexture = assetManagerProvider.GetAssetManager().Get<TextureAsset>("texture.Logo");

            this.m_WorldFactory = worldFactory;

            this.Entities = new List<IEntity>();

            var startServer = new Button();
            startServer.Text = "Start Server";
            startServer.Click += (sender, e) =>
            {
                this.m_LastGameContext.SwitchWorld<IWorldFactory>(
                    x => x.CreateLobbyWorld(false, IPAddress.Any));
            };

            var ipAddressTextBox = new TextBox();

            var joinGame = new Button();
            joinGame.Text = "Join Game";
            joinGame.Click += (sender, e) =>
            {
                this.m_LastGameContext.SwitchWorld<IWorldFactory>(
                    x => x.CreateLobbyWorld(true, IPAddress.Parse(ipAddressTextBox.Text)));
            };

            var exitGame = new Button();
            exitGame.Text = "Exit Game";
            exitGame.Click += (sender, e) =>
            {
                this.m_LastGameContext.Game.Exit();
            };

            var vertical = new VerticalContainer();
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(new Label { Text = "Perspective" }, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(startServer, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(new Label { Text = "Server IP address:" }, "20");
            vertical.AddChild(ipAddressTextBox, "20");
            vertical.AddChild(joinGame, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(exitGame, "25");
            vertical.AddChild(new EmptyContainer(), "*");

            var horizontal = new HorizontalContainer();
            horizontal.AddChild(new EmptyContainer(), "*");
            horizontal.AddChild(vertical, "250");
            horizontal.AddChild(new EmptyContainer(), "*");

            var canvas = new Canvas();
            canvas.SetChild(horizontal);

            this.Entities.Add(new CanvasEntity(skin, canvas));
        }
Exemplo n.º 3
0
 public Application(
     IWorldFactory worldFactory,
     IParserService parserService,
     IDisplayService displayService)
 {
     _worldFactory   = worldFactory;
     _parserService  = parserService;
     _displayService = displayService;
 }
Exemplo n.º 4
0
 /// <summary>Initializes a new instance of the GameBase class</summary>
 /// <param name="definition">Game definition</param>
 /// <param name="resources">Resource library</param>
 /// <param name="worldFactory">World factory</param>
 /// <param name="inputManager">Input manager</param>
 protected GameBase(GameDefinition definition, IResourceLibrary resources, IWorldFactory worldFactory, IInputManager inputManager)
 {
     this.Id           = new RuntimeId(definition.Id);
     this.Title        = definition.Title;
     this.Resources    = resources;
     this.WorldFactory = worldFactory;
     this.InputManager = inputManager;
     this.levelIds     = definition.LevelIds;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Builds a game world based on world type.
        /// </summary>
        /// <param name="worldType">The <see cref="WorldType"/> to build.</param>
        /// <returns>The constructed <see cref="GameWorld"/>.</returns>
        public static GameWorld BuildGameWorld(WorldType worldType)
        {
            IWorldFactory factory = null;

            switch (worldType)
            {
            case WorldType.FireWorld:
                factory = new FireWorldFactory();
                break;

            case WorldType.IceWorld:
                factory = new IceWorldFactory();
                break;

            case WorldType.DarkWorld:
                factory = new DarkWorldFactory();
                break;
            }

            return(factory.ConstructWorld());
        }
Exemplo n.º 6
0
 public GameFactory(
     IGameStateService gameStateService,
     IDatabaseService databaseService,
     ILogService logService,
     IConfigurator configurator,
     IRandomService randomService,
     IUniverseFactory universeFactory,
     IWorldFactory worldFactory,
     IAreaFactory areaFactory,
     ISectionFactory sectionFactory)
 {
     this.gameStateService = gameStateService;
     this.databaseService  = databaseService;
     this.logService       = logService;
     this.configurator     = configurator;
     this.randomService    = randomService;
     this.universeFactory  = universeFactory;
     this.worldFactory     = worldFactory;
     this.areaFactory      = areaFactory;
     this.sectionFactory   = sectionFactory;
 }
Exemplo n.º 7
0
 public ClientService(ISerializer serializer, ICoordinator coordinator, IWorldFactory worldFactory)
 {
     _serializer = serializer;
     _coordinator = coordinator;
     _worldFactory = worldFactory;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="WorldManager"/> class.
 /// </summary>
 /// <param name="worldFactory">The factory responsible for creating new worlds.</param>
 public WorldManager(IWorldFactory worldFactory)
 {
     this.worlds       = new List <IWorld>();
     this.worldFactory = worldFactory;
 }
Exemplo n.º 9
0
        public MenuWorld(ISkin skin, IWorldFactory worldFactory, IAssetManagerProvider assetManagerProvider, I2DRenderUtilities twodRenderUtilities)
        {
            this.m_2DRenderUtilities = twodRenderUtilities;

            this.m_LogoTexture = assetManagerProvider.GetAssetManager().Get <TextureAsset>("texture.Logo");

            this.m_WorldFactory = worldFactory;

            this.Entities = new List <IEntity>();

            var startServer = new Button();

            startServer.Text   = "Start Server";
            startServer.Click += (sender, e) =>
            {
                this.m_LastGameContext.SwitchWorld <IWorldFactory>(
                    x => x.CreateLobbyWorld(false, IPAddress.Any));
            };

            var ipAddressTextBox = new TextBox();

            var joinGame = new Button();

            joinGame.Text   = "Join Game";
            joinGame.Click += (sender, e) =>
            {
                this.m_LastGameContext.SwitchWorld <IWorldFactory>(
                    x => x.CreateLobbyWorld(true, IPAddress.Parse(ipAddressTextBox.Text)));
            };

            var exitGame = new Button();

            exitGame.Text   = "Exit Game";
            exitGame.Click += (sender, e) =>
            {
                this.m_LastGameContext.Game.Exit();
            };

            var vertical = new VerticalContainer();

            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(new Label {
                Text = "Perspective"
            }, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(startServer, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(new Label {
                Text = "Server IP address:"
            }, "20");
            vertical.AddChild(ipAddressTextBox, "20");
            vertical.AddChild(joinGame, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(exitGame, "25");
            vertical.AddChild(new EmptyContainer(), "*");

            var horizontal = new HorizontalContainer();

            horizontal.AddChild(new EmptyContainer(), "*");
            horizontal.AddChild(vertical, "250");
            horizontal.AddChild(new EmptyContainer(), "*");

            var canvas = new Canvas();

            canvas.SetChild(horizontal);

            this.Entities.Add(new CanvasEntity(skin, canvas));
        }
Exemplo n.º 10
0
 /// <summary>Initializes a new instance of the UnityGame class</summary>
 /// <param name="definition">Game definition</param>
 /// <param name="resources">Resource library</param>
 /// <param name="worldFactory">World factory</param>
 /// <param name="inputManager">Input manager</param>
 public UnityGame(GameDefinition definition, IResourceLibrary resources, IWorldFactory worldFactory, IInputManager inputManager)
     : base(definition, resources, worldFactory, inputManager)
 {
 }
Exemplo n.º 11
0
 /// <summary>Initializes a new instance of the GameFactoryBase class</summary>
 /// <param name="resources">Resource library</param>
 /// <param name="worldFactory">World factory</param>
 /// <param name="inputManager">Input manager</param>
 protected GameFactoryBase(IResourceLibrary resources, IWorldFactory worldFactory, IInputManager inputManager)
     : base(resources)
 {
     this.WorldFactory = worldFactory;
     this.InputManager = inputManager;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WorldManager"/> class.
 /// </summary>
 /// <param name="worldFactory">The factory responsible for creating new worlds.</param>
 public WorldManager(IWorldFactory worldFactory)
 {
     this.worlds = new List<IWorld>();
     this.worldFactory = worldFactory;
 }