Exemplo n.º 1
0
        static GameConfig()
        {
            // Чтение из файла
            var fileLines = File.ReadAllLines("ip.txt");

            Configs = new Dictionary <int, GameConfig>
            {
                [1] = new GameConfig
                {
                    Player = GameObjectFactory.CreatePlayer(
                        new Vector4(1.0f, 1.0f, 0.0f, 1.0f),
                        new Vector2(2, 0.5f),
                        ComponentsFactory.CreateControlSettings(Keys.W, Keys.S, Keys.A, Keys.D, Keys.Space, Keys.C)),
                    ServerAdress = fileLines[0],
                    Port         = 8080
                },
                [2] = new GameConfig
                {
                    Player = GameObjectFactory.CreatePlayer(
                        new Vector4(0.0f, 1.0f, 0.0f, 1.0f),
                        new Vector2(-2, 0.5f),
                        ComponentsFactory.CreateControlSettings(Keys.NumPad8, Keys.NumPad2, Keys.NumPad4, Keys.NumPad6, Keys.NumPad0, Keys.NumPad1)),
                    ServerAdress = fileLines[1],
                    Port         = 8000
                }
            };
        }
Exemplo n.º 2
0
        public void generate()
        {
            foreach (XmlNode table in xml.DocumentElement.ChildNodes)
            {
                switch (table.Name)
                {
                case "space":
                {
                    SpaceFactory.generate(GCore.Resource.getXml(table.Attributes["src"].Value));
                } break;

                case "components":
                {
                    ComponentsFactory.generate(GCore.Resource.getXml(table.Attributes["src"].Value));
                } break;
                }
            }
        }
Exemplo n.º 3
0
        public Form1(int applicationId)
        {
            this.gameConfig        = GameConfig.Configs[applicationId];
            this.enemyServerAddres = applicationId == 1
                ? GameConfig.Configs[2].ServerAdress
                : GameConfig.Configs[1].ServerAdress;
            this.enemyServerPort = applicationId == 1
                ? GameConfig.Configs[2].Port
                : GameConfig.Configs[1].Port;

            // Создание сервисов и репозиториев
            gameRepository    = ComponentsFactory.CreateGameRepository();
            gameActionService = ServiceFactory.CreateGameActionService();

            CreateAreas();
            CreatePlayers();
            CreateWalls();

            drawingService = ServiceFactory.CreateDrawingService();

            InitializeComponent();

            Task.Run(() =>
            {
                //RunServer();
                RunCPPServer();
            });

            Task.Run(() =>
            {
                while (!isGameEnd)
                {
                    glControl1.Invalidate();

                    Thread.Sleep(100);
                }
            });
        }