Beispiel #1
0
        public void OnEnter()
        {
            Console.Clear();
            location = gameMap.GetLocation(playerSystem.GetCurrentLocation(playerSystem.CurrentPlayer));
            instance = new CombatInstance(lua, combatSystem);

            List<IRDSObject> enemy = location.GetEnemy().ToList();
            if (enemy.Count == 0) OnEnter();

            for (int i = 0; i < enemy.Count; i++)
            {
                if (!(enemy[i] is Entity)) continue;

                AddEntityToCombat((Entity)enemy[i], playerSystem.CurrentPlayer);
            }
            Console.ReadKey();
            instance.AddEntity(playerSystem.CurrentPlayer);
            combatSystem.Heal(playerSystem.CurrentPlayer, StatType.CUR_STAMINA, combatSystem.GetCurrentStat(playerSystem.CurrentPlayer, StatType.MAX_STAMINA));
        }
Beispiel #2
0
        public void InitializeMapFromXML(string data)
        {
            XmlDocument doc=new XmlDocument();
            doc.Load(data);
            XmlNode baseNode = doc.FirstChild;
            baseNode = baseNode.NextSibling;

            int locationCount=baseNode.ChildNodes.Count;

            XmlNode locationNode= baseNode.FirstChild;

            for (int i = 0; i < locationCount; i++)
            {
                string name = locationNode.Attributes[1].Value;
                string type = locationNode.Attributes[2].Value;
                string descript = locationNode.Attributes[3].Value;
                int restCost = Convert.ToInt32(locationNode.Attributes[4].Value);
                XmlNode adjacentNode = locationNode.FirstChild;

                int count = adjacentNode.ChildNodes.Count;
                string[] adjacent = new string[count];

                adjacentNode = adjacentNode.FirstChild;
                for (int j = 0; j < count; j++)
                {
                    adjacent[j] = adjacentNode.Attributes[0].Value;
                    adjacentNode = adjacentNode.NextSibling;
                }
                
                LocationType t=LocationType.TOWN;
                switch(type)
                {
                    case "Field":
                        t=LocationType.FIELD;
                        break;
                    case "Dungeon":
                        t=LocationType.DUNGEON;
                        break;

                }

                Location newLocation = new Location(name, t);
                string locationID = locationNode.Attributes[0].Value;
                AddLocation(locationID, newLocation);

                for (int j = 0; j < count; j++)
                {
                    AddAdjacent(locationID, adjacent[j]);
                }

                if (type != "Town")
                {
                    XmlNode enemyNode=locationNode.FirstChild.NextSibling;
                    newLocation.SetEncounters(Convert.ToInt32(enemyNode.Attributes[0].Value), Convert.ToDouble(enemyNode.Attributes[1].Value));
                    count=enemyNode.ChildNodes.Count;
                    enemyNode=enemyNode.FirstChild;
                    for (int j = 0; j < count; j++)
                    {
                        newLocation.AddEntityToTable(enemyNode.Attributes[0].Value, Convert.ToDouble(enemyNode.Attributes[1].Value));
                        enemyNode = enemyNode.NextSibling;
                    }
                }
                
                newLocation.SetIntroduction(descript);
                newLocation.SetRestCost(restCost);
                

                locationNode = locationNode.NextSibling;                
            }

        }
Beispiel #3
0
        public void AddLocation(string name, Location location)
        {
            System.Diagnostics.Debug.Assert(!locationMap.Keys.Contains(name));

            locationMap.Add(name, location);
        }