Esempio n. 1
0
        private void AnalysisOfFileLevel(FileInfo fileLevel)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(fileLevel.FullName);

            XmlElement xmlRoot = xmlDoc.DocumentElement;  //Get root element.

            AnalisisAttributesRoot(xmlRoot);

            List <Platform> platforms = new List <Platform>();

            int id = 0;

            if (xmlRoot != null)
            {
                foreach (XmlNode xmlPlatform in xmlRoot) //Get childs root.
                {
                    Platform platform = new Platform();
                    platform.IdPlatform = id++;

                    if (xmlPlatform.Name == "platform")
                    {
                        if (xmlPlatform.Attributes.Count > 0)
                        {
                            platform.NamePlatform = GetValueOfAttribute(xmlPlatform, "Name", true).Value;

                            {
                                int indexType = Convert.ToInt32(GetValueOfAttribute(xmlPlatform, "Type", true).Value);
                                platform.TypePlatform = (TypesPlatform)indexType;
                            }
                        }
                        else
                        {
                            Debug.LogError("EL_003: некорректные атрибуты платформы");
                        }

                        if (xmlPlatform.HasChildNodes)
                        {
                            foreach (XmlNode xmlChild in xmlPlatform)
                            {
                                if (xmlChild.Name == "item")
                                {
                                    Item item = new Item();

                                    XmlNode xmlItem = xmlChild; // Get child xmlPlatform.

                                    if (xmlItem.Attributes != null && xmlItem.Attributes.Count > 0)
                                    {
                                        item.NameItem = GetValueOfAttribute(xmlItem, "Name", true).Value;

                                        {
                                            int indexType = Convert.ToInt32(GetValueOfAttribute(xmlItem, "Type", true).Value);
                                            item.TypeItem = (TypesItem)indexType;
                                        }

                                        platform.ItemOnPlatform = item;
                                    }
                                }

                                if (xmlChild.Name == "tank")
                                {
                                    Tank    tank    = new Tank();
                                    XmlNode xmlTank = xmlChild;  // Get child xmlPlatform.

                                    if (xmlTank.Attributes != null && xmlTank.Attributes.Count > 0)
                                    {
                                        tank.NameTank = GetValueOfAttribute(xmlTank, "Name", true).Value;

                                        {
                                            int indexType = Convert.ToInt32(GetValueOfAttribute(xmlTank, "Type", true).Value);
                                            tank.TypeTank = (TypesTank)indexType;
                                        }

                                        if (GetValueOfAttribute(xmlTank, "Rotate", false) != null)
                                        {
                                            tank.RotateTank = Convert.ToInt32(GetValueOfAttribute(xmlTank, "Rotate", false).Value);
                                        }

                                        if (GetValueOfAttribute(xmlTank, "TargetPoint", false) != null)
                                        {
                                            tank.TargetPoint = GetValueOfAttribute(xmlTank, "TargetPoint", false).Value;
                                        }

                                        platform.TankOnPlatform = tank;
                                    }
                                }
                            }
                        }
                    }

                    platforms.Add(platform);
                }
            }

            dates.Platforms = platforms;
        }
Esempio n. 2
0
 public void RemoveTankOnPlatform()
 {
     tankOnPlatform = null;
 }