예제 #1
0
    public void LoadChessBoardFromXML()
    {
        string filePath = Application.dataPath + "/Resources/XML/ChessBoardConfig/" + GameMapID + ".xml";

        if (File.Exists(filePath))
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(filePath);
            XmlNodeList node = xmlDoc.SelectSingleNode("ChessBoardConfig").ChildNodes;
            foreach (XmlElement ChessBoardInfo in node)
            {
                foreach (XmlElement ChessBoardInfoItem in ChessBoardInfo.ChildNodes)
                {
                    if (ChessBoardInfoItem.Name == "Coordinate")
                    {
                        MainWorldManager.CreateChessboard(PublicUtility.StringToVector2Int(ChessBoardInfoItem.InnerText));
                    }
                    else if (ChessBoardInfoItem.Name == "DisableCheckerBoard")
                    {
                        foreach (XmlElement DisableCheckerBoardInfoItem in ChessBoardInfoItem.ChildNodes)
                        {
                            Debug.Log(DisableCheckerBoardInfoItem.InnerText);
                        }
                    }
                }
            }
        }
    }
예제 #2
0
    public void LoadInitialPieceFromXML()
    {
        string filePath = Application.dataPath + "/Resources/XML/InitialPieceConfig/" + GameMapID + ".xml";

        if (File.Exists(filePath))
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(filePath);
            XmlNodeList node = xmlDoc.SelectSingleNode("InitialPieceConfig").ChildNodes;
            foreach (XmlElement InitialPieceInfo in node)
            {
                string     CurrentPieceID         = "";
                Vector2Int CurrentOuterCoordinate = new Vector2Int();
                Vector2Int CurrentInnerCoordinate = new Vector2Int();

                foreach (XmlElement InitialPieceInfoItem in InitialPieceInfo.ChildNodes)
                {
                    if (InitialPieceInfoItem.Name == "PieceID")
                    {
                        CurrentPieceID = InitialPieceInfoItem.InnerText;
                    }
                    else if (InitialPieceInfoItem.Name == "OuterCoordinate")
                    {
                        CurrentOuterCoordinate = PublicUtility.StringToVector2Int(InitialPieceInfoItem.InnerText);
                    }
                    else if (InitialPieceInfoItem.Name == "InnerCoordinate")
                    {
                        CurrentInnerCoordinate = PublicUtility.StringToVector2Int(InitialPieceInfoItem.InnerText);
                    }
                    else if (InitialPieceInfoItem.Name == "Orientation")
                    {
                        Debug.Log(InitialPieceInfoItem.InnerText);
                    }
                }

                MainWorldManager.CreatePieceOnChessboard(CurrentPieceID, CurrentInnerCoordinate, CurrentOuterCoordinate);
            }
        }
    }