コード例 #1
0
        bool ParseXMLTemplateFile(String aFile, ActorTemplate aTemplate)
        {
            bool        lResult = false;
            XmlDocument doc     = new XmlDocument();

            doc.Load(aFile);
            foreach (XmlNode lNode in doc.DocumentElement.ChildNodes)
            {
                lResult = ParseXMLTemplateNode(lNode, aTemplate);
            }
            return(lResult);
        }
コード例 #2
0
        bool ParseXMLTemplateNode(XmlNode aNode, ActorTemplate aTemplate)
        {
            bool lResult = true;

            switch (aNode.Name)
            {
            case "Name":
                aTemplate.Name = aNode.InnerText;
                break;

            case "Level":
                aTemplate.Level = Convert.ToInt32(aNode.InnerText);
                break;

            case "MaxHealth":
                aTemplate.MaxHealth = Convert.ToInt32(aNode.InnerText);
                break;

            case "Str":
                aTemplate.Str = Convert.ToInt32(aNode.InnerText);
                break;

            case "Dex":
                aTemplate.Dex = Convert.ToInt32(aNode.InnerText);
                break;

            case "Int":
                aTemplate.Int = Convert.ToInt32(aNode.InnerText);
                break;

            case "Item":
                //aTemplate.Name = aNode.InnerText;
                break;

            case "Tag":
                if (aNode.Value != null)
                {
                    aTemplate.Tags.AddTag(aNode.InnerText);
                }
                break;

            default:
                lResult = false;
                break;
            }
            return(lResult);
        }
コード例 #3
0
        public Actor(String aName, ActorTemplate aTemplate, int aX, int aY, int aGroup)
        {
            this.Name      = aName;
            this.Stats     = aTemplate;
            this.Inventory = new List <Item> ();
            this.Group     = aGroup;
            this.pos.x     = aX;
            this.pos.y     = aY;
            this.Health    = this.Stats.MaxHealth;

            Body = new Dictionary <string, ActorBodyPart> ();
            Body.Add("LeftHand", new ActorBodyPart("LeftHand"));
            Body.Add("RightHand", new ActorBodyPart("RightHand"));
            Body.Add("Head", new ActorBodyPart("Head"));
            Body.Add("Torso", new ActorBodyPart("Torso"));
            Body.Add("Legs", new ActorBodyPart("Legs"));
        }
コード例 #4
0
        public ActorGenerator()
        {
            ActorLevelList = new List <ActorTemplate>();
            ActorNames     = new List <string>();
            PlayerTemplate = new ActorTemplate();

            foreach (string lFile in Directory.EnumerateFiles("/home/terry/Documents/Personal/roguelike/RogueLike/RogueLike/Data/Enemies/Template", "*.xml"))
            {
                ActorTemplate lActorTemplate = new ActorTemplate();
                if (ParseXMLTemplateFile(lFile, lActorTemplate))
                {
                    ActorLevelList.Add(lActorTemplate);
                }
            }

            foreach (string lFile in Directory.EnumerateFiles("/home/terry/Documents/Personal/roguelike/RogueLike/RogueLike/Data/Enemies/Names", "*.xml"))
            {
                ParseXMLNameFile(lFile);
            }

            ParseXMLTemplateFile("/home/terry/Documents/Personal/roguelike/RogueLike/RogueLike/Data/Player/Player.xml", this.PlayerTemplate);
        }
コード例 #5
0
        public ConfigData()
        {
            ActorDic       = new Dictionary <string, ActorTemplate> ();
            ItemDic        = new Dictionary <string, Item> ();
            ActorNames     = new List <string>();
            PlayerTemplate = new ActorTemplate();

            //Get Actor Names
            foreach (string lFile in Directory.EnumerateFiles(DataLocation + "Enemies/Names", "*.xml"))
            {
                ParseXMLNameFile(lFile);
            }

            //Get Enemy Templates
            foreach (string lFile in Directory.EnumerateFiles(DataLocation + "Enemies/Template", "*.xml"))
            {
                ActorTemplate lActorTemplate = new ActorTemplate();
                if (ParseXMLActorTemplateFile(lFile, lActorTemplate))
                {
                    ActorDic.Add(lActorTemplate.Name, lActorTemplate);
                }
            }

            //Get Player Templates
            ParseXMLActorTemplateFile(DataLocation + "Player/Player.xml", this.PlayerTemplate);

            //Get Templates Item
            foreach (string lFile in Directory.EnumerateFiles(DataLocation + "Items", "*.xml"))
            {
                Item lItem = null;
                if (ParseXMLItemFile(lFile, out lItem))
                {
                    ItemDic.Add(lItem.GetName(), lItem);
                }
            }
        }
コード例 #6
0
ファイル: Enemy.cs プロジェクト: Obsnold/Simple_Roguelike
 public Enemy(String aName, ActorTemplate aTemplate, int aX, int aY, int aGroup) :
     base(aName, aTemplate, aX, aY, aGroup)
 {
 }
コード例 #7
0
        bool ParseXMLActorTemplateFile(String aFile, ActorTemplate aTemplate)
        {
            bool        lResult = true;
            XmlDocument doc     = new XmlDocument();

            doc.Load(aFile);
            foreach (XmlNode lNode in doc.DocumentElement.ChildNodes)
            {
                switch (lNode.Name)
                {
                case "Name":
                    aTemplate.Name = lNode.InnerText;
                    break;

                case "Level":
                    aTemplate.Level = Convert.ToInt32(lNode.InnerText);
                    break;

                case "MaxHealth":
                    aTemplate.MaxHealth = Convert.ToInt32(lNode.InnerText);
                    break;

                case "Str":
                    aTemplate.Str = Convert.ToInt32(lNode.InnerText);
                    break;

                case "Con":
                    aTemplate.Con = Convert.ToInt32(lNode.InnerText);
                    break;

                case "Dex":
                    aTemplate.Dex = Convert.ToInt32(lNode.InnerText);
                    break;

                case "Ref":
                    aTemplate.Ref = Convert.ToInt32(lNode.InnerText);
                    break;

                case "Int":
                    aTemplate.Int = Convert.ToInt32(lNode.InnerText);
                    break;

                case "Wis":
                    aTemplate.Wis = Convert.ToInt32(lNode.InnerText);
                    break;

                case "Item":
                    //aTemplate.Name = aNode.InnerText;
                    break;

                case "Tag":
                    if (lNode.Value != null)
                    {
                        aTemplate.Tags.AddTag(lNode.InnerText);
                    }
                    break;

                default:
                    lResult = false;
                    break;
                }
            }
            return(lResult);
        }