コード例 #1
0
        private void parseListXML(string xml)
        {
            bool endOfList = false;
            XmlReader reader = XmlReader.Create(new StringReader(xml));

            while (!endOfList)
            {
                try
                {
                    reader.ReadToFollowing("Requirements");
                    string type = reader.GetAttribute("type");

                    if (type.ToUpper().Equals("BUILDING"))
                    {
                        string btype = reader.GetAttribute("btype");
                        BuildingStats bstats = BuildingFactory.Instance.getStats(btype);
                        if (bstats != null)
                        {
                            string innerXML = reader.ReadInnerXml();
                            ReqList reqList = new ReqList(innerXML, bstats);
                            this.buildingReqs.Add(bstats, reqList);
                        }

                    }
                    else if (type.ToUpper().Equals("UNIT"))
                    {
                        string utype = reader.GetAttribute("utype");
                        UnitStats ustats = UnitFactory.Instance.getStats(utype);

                        if (ustats != null)
                        {
                            string innerXML = reader.ReadInnerXml();
                            ReqList reqList = new ReqList(innerXML, ustats);
                            this.unitReqs.Add(ustats, reqList);
                        }
                    }

                }
                catch
                {
                    endOfList = true;
                }
            }
            reader.Close();
        }
コード例 #2
0
        /// <summary>
        /// This function will deterimine if a Player meets the requirements to produce a Unit.
        /// </summary>
        /// <param name="player">Player being tested</param>
        /// <param name="ustats">UnitStats defining the Unit</param>
        /// <returns>true if the player meets the requirements, false if the player does not.</returns>
        public bool playerMeetsRequirements(Player.Player player, UnitStats ustats)
        {
            ReqList reqList = unitReqs[ustats];

            return(reqList.playerMeetsReqs(player));
        }