These (byte) values are for "well known" room/game properties used in Photon Loadbalancing.
"Custom properties" have to use a string-type as key. They can be assigned at will.
Пример #1
0
        public async Task<Game> CreateSinglePlayerGameAsync(Player player, GameProperties properties)
        {
            var gameBoard = GameBoard.New(properties, player, Player.ComputerPlayer);
            var status = GameStatus.CreateActive(player, Player.ComputerPlayer);
            var game = new Game(0, player, Player.ComputerPlayer, status, gameBoard);
            var results = await repository.CreateAsync(game);

            return results;
        }
Пример #2
0
 public void GameBoard_Get_InvalidMove_Positive()
 {
     var rows = 8;
     var cols = 8;
     var props = new GameProperties(new Bounds(rows, cols), 2, 2);
     var tokens = new[] { new Token(1, "player1", TokenType.Flag, 1, 2), new Token(1, "player2", TokenType.Flag, 3, 4) };
     var gameBoard = new GameBoard(props, tokens);
     gameBoard.Get(100, 100); // throws
 }
Пример #3
0
        public void GameBoard_GetTokens()
        {
            int rows = 6;
            int cols = 6;
            var props = new GameProperties(new Bounds(rows, cols), 2, 2);
            var tokens = new[] { new Token(1, "player1", TokenType.Flag, 1, 2), new Token(1, "player2", TokenType.Flag, 3, 4) };
            var gameBoard = new GameBoard(props, tokens);

            CollectionAssert.AreEquivalent(tokens.OrderBy(x => x.Row).ThenBy(x => x.Col).ToArray(), 
                                          gameBoard.GetTokens().OrderBy(x => x.Row).ThenBy(x => x.Col).ToArray(), 
                                          "GetTokens should return an equivelant collection to input collection");
        }
Пример #4
0
        public void GameBoard_Get()
        {
            var rows = 8;
            var cols = 8;
            var props = new GameProperties(new Bounds(rows, cols), 2, 2);
            var tokens = new[] { new Token(1, "player1", TokenType.Flag, 1, 2), new Token(1, "player2", TokenType.Flag, 3, 4) };
            var gameBoard = new GameBoard(props, tokens);

            Assert.AreEqual(rows, gameBoard.NumRows, "NumRows should be correct");
            Assert.AreEqual(cols, gameBoard.NumCols, "NumCols should be correct");
            Assert.AreEqual(tokens[0], gameBoard.Get(1, 2), "1,2 should return the first token");
            Assert.AreEqual(tokens[1], gameBoard.Get(3, 4), "3,4 should return the second token");
            Assert.IsNull(gameBoard.Get(1, 1), "1,1 should return null");
        }
Пример #5
0
 /// <summary>
 /// Inform the game that a game property has been changed. This will invoke the
 /// PropertyChanged event and cause the property grids to be updated.
 /// </summary>
 public static void InformPropertyChanged(GameProperties property)
 {
     if (PropertyChanged != null)
         PropertyChanged(property);
 }
Пример #6
0
        private String ParseResourceXML(String resourceXMLPath)
        {
            XmlDocument document = new XmlDocument();

            GamePropertiesInfo = new GameProperties();

            try
            {
                document.Load(resourceXMLPath);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString(), "Ошибка загрузки XML");
                return "";
            }

            string xpathApplication = "/Resources";

            XmlNode gamenode =
                        document.SelectSingleNode(xpathApplication);

            String resourcePath = "";

            foreach (XmlNode node in gamenode.ChildNodes)
            {
                switch (node.Name.ToLower())
                {
                    case "resource":
                        {
                            String value = node.Attributes[0].Value;
                            String name = node.ChildNodes.Item(0).Name;
                            String vn = System.IO.Path.Combine(value, name);

                            String gamedir = GetFullGameXMLPath();
                            resourcePath = System.IO.Directory.GetParent(gamedir).FullName;
                            resourcePath = System.IO.Path.Combine(resourcePath, vn);
                            resourcePath += ".resource";

                            break;
                        }
                }
            }

            return resourcePath;
        }
Пример #7
0
        private void ParseGameXML(String gameXMLPath)
        {
            GameXMLPath = gameXMLPath;

            XmlDocument document = new XmlDocument();

            GamePropertiesInfo = new GameProperties();

            try
            {
                document.Load(gameXMLPath);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString(), "Ошибка загрузки XML");
                return;
            }

            string xpathApplication = "/Game";

            try
            {
                XmlNode gamenode =
                        document.SelectSingleNode(xpathApplication);

                foreach (XmlNode node in gamenode.ChildNodes)
                {
                    String value = node.Attributes[0].Value;

                    switch (node.Name.ToLower())
                    {
                  /*      case "title":
                            {
                                GamePropertiesInfo.Title = value;
                                break;
                            }
                        case "resourceresolution":
                            {
                                GamePropertiesInfo.ResourceResolution = value;
                                break;
                            }
                        case "fixedcontentresolution":
                            {
                                GamePropertiesInfo.FixedContentResolution = value;
                                break;
                            }
                        case "personalitymodule":
                            {
                                GamePropertiesInfo.PersonalityModule = value;
                                break;
                            }
                        case "initfunction":
                            {
                                GamePropertiesInfo.InitFunction = value;
                                break;
                            }
                        case "updatefunction":
                            {
                                GamePropertiesInfo.UpdateFunction = value;
                                break;
                            }
                        case "finilizefunction":
                            {
                                GamePropertiesInfo.FinilizeFunction = value;
                                break;
                            }
                        case "defaultarrow":
                            {
                                GamePropertiesInfo.DefaultArrow = value;
                                break;
                            }
                        case "width":
                            {
                                GamePropertiesInfo.Width = Convert.ToInt32(value);
                                break;
                            }
                        case "height":
                            {
                                GamePropertiesInfo.Height = Convert.ToInt32(value);
                                break;
                            }
                        case "bits":
                            {
                                GamePropertiesInfo.Bits = Convert.ToInt32(value);
                                break;
                            }
                        case "fullscreen":
                            {
                                GamePropertiesInfo.Fullscreen = Convert.ToInt32(value);
                                break;
                            }*/
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString(), "Ошибка чтения XML");
                return;
            }
        }
 // Use this for initialization
 void Start()
 {
     m_gameproperties = m_instance.GetComponent<GameProperties>();
     m_inputmanager = gameObject.AddComponent<InputManager>();
     m_gamestatemanager = gameObject.AddComponent<GameStateManager>();
     m_commandmanager = gameObject.AddComponent<CommandManager>();
     m_loadmanager = gameObject.AddComponent<LoadManager>();
     m_enemymanager = gameObject.AddComponent<EnemyManager>();
     m_guimanager = gameObject.AddComponent<GUIManager>();
     m_bulletPoolManager = gameObject.AddComponent<BulletPoolManager>();
     m_enemyPoolManager = gameObject.AddComponent<EnemyPoolManager>();
     m_gamestatemanager.Init();
 }