コード例 #1
0
ファイル: XmlLoader.cs プロジェクト: hainam2101/Strategy
        /// <summary>
        /// Finds information for RunTimeCreator by the given name and collects arguments. After that creates the instance
        /// of the IStaticGameObject.
        /// </summary>
        /// <param name="gameObject">The XmlNode with creating object type and arguments.</param>
        /// <param name="isgoType">Represents if the creating type is a Sun ro not.</param>
        /// <returns>
        /// Returns created IStaticGameObject.
        /// </returns>
        /// <exception cref="System.Xml.XmlException">Thrown when the team of the creating object is not exist.</exception>
        private IStaticGameObject CreateISGO(XmlNode gameObject, IsgoType isgoType)
        {
            string        type;
            List <object> args = new List <object>();

            args.Add(runtimeCtor.GetUnusedName(gameObject.Attributes["name"].InnerText));
            var    teamNode = gameObject.Attributes["team"];
            string team     = "Sun";

            if (teamNode != null)
            {
                team = gameObject.Attributes["team"].InnerText;
            }

            if (isgoType == IsgoType.Sun)
            {
                type = IsgoType.Sun.ToString();
            }
            else
            {
                if (!teamDict.ContainsKey(team))
                {
                    throw new XmlException("Undefined Team " + team + " .");
                }
                args.Add(teamDict[team]);
                type = gameObject.Attributes["type"].InnerText;
            }

            var argList = LoadArguments(gameObject);

            args.Add(argList.ToArray());

            var isgo = CreateISGO(type, args.ToArray());

            return(isgo);
        }
コード例 #2
0
        /// <summary>
        /// Finds information for RunTimCreator by the given name and collects arguments. After that creates the instance 
        /// of the IStaticGameObject. 
        /// </summary>
        /// <param name="gameObject">The XmlNode with creating object type and arguments.</param>
        /// <param name="isgoType">Represents if the creating type is a Sun ro not.</param>
        /// <returns>Returns created IStaticGameObject.</returns>
        private IStaticGameObject CreateISGO(XmlNode gameObject, IsgoType isgoType)
        {
            string type;
            List<object> args = new List<object>();

            args.Add(runtimeCtor.GetUnusedName(gameObject.Attributes["name"].InnerText));
            var teamNode = gameObject.Attributes["team"];
            string team = "Sun";
            if (teamNode != null) {
                team = gameObject.Attributes["team"].InnerText;
            }

            if (isgoType == IsgoType.Sun) {
                type = IsgoType.Sun.ToString();
            } else {
                if (!teamDict.ContainsKey(team)) {
                    throw new XmlException("Undefined Team " + team + " .");
                }
                args.Add(teamDict[team]);
                type = gameObject.Attributes["type"].InnerText;
            }

            var argList = LoadArguments(gameObject);
            args.Add(argList.ToArray());

            var isgo = CreateISGO(type, args.ToArray());

            return isgo;
        }