static public void Init() { Shops.Clear(); foreach (var shopXmlFile in GameProject.GetFiles("shop")) { string path = "Scripts/" + shopXmlFile; XElement xmlRoot = Tools.LoadXml(path); foreach (var shopXml in xmlRoot.Elements("shop")) { Shop shop = new Shop(); shop.Name = Tools.GetXmlAttribute(shopXml, "name"); shop.PicUrl = ResourceManager.Get(Tools.GetXmlAttribute(shopXml, "pic")); shop.Music = Tools.GetXmlAttribute(shopXml, "music"); if (shopXml.Attribute("key") != null) { shop.Key = Tools.GetXmlAttribute(shopXml, "key"); } else //如果没有定义key,则默认把name作为key(key是作为是否购买限制物品的标识) { shop.Key = shop.Name; } foreach (var sale in shopXml.Elements("sale")) { shop.Sales.Add(ShopItem.Parse(sale)); } Shops.Add(shop); } } }
static public void Init() { Battles.Clear(); MapTemplates.Clear(); Arenas.Clear(); Towers.Clear(); foreach (var mapXmlFile in GameProject.GetFiles("battle")) { XElement xmlRoot = Tools.LoadXml("Scripts/" + mapXmlFile); foreach (XElement node in xmlRoot.Element("maptemplates").Elements("maptemplate")) { MapTemplate template = MapTemplate.Parse(node); MapTemplates.Add(template); } foreach (XElement node in xmlRoot.Element("battles").Elements("battle")) { Battle battle = Battle.Parse(node); Battles.Add(battle); //如果是arena地图,则加入arena中 if (battle.arena == "yes") { Arenas.Add(battle); } } } }
static public void Init() { triggerList.Clear(); foreach (string triggerFile in GameProject.GetFiles("timetrigger")) { XElement xmlRoot = Tools.LoadXml("Scripts/" + triggerFile); foreach (XElement times in xmlRoot.Elements("time")) { int day = Tools.GetXmlAttributeInt(times, "day"); string storyDialog = Tools.GetXmlAttribute(times, "story"); TimeTrigger tt = new TimeTrigger(); tt.time = day; tt.story = storyDialog; if (times.Element("condition") != null) { foreach (var c in times.Elements("condition")) { EventCondition cd = EventCondition.Parse(c); tt.conditions.Add(cd); } } triggerList.Add(tt); } } }
static public void Init() { ResourceMap.Clear(); foreach (var resourceXmlFile in GameProject.GetFiles("resources")) { XElement xmlRoot = Tools.LoadXml("Scripts/" + resourceXmlFile); foreach (XElement t in xmlRoot.Elements()) { ResourceMap.Add(Tools.GetXmlAttribute(t, "key"), Tools.GetXmlAttribute(t, "value")); } } }
static public void Init() { Shops.Clear(); foreach (var shopXmlFile in GameProject.GetFiles("shop")) { string path = "Scripts/" + shopXmlFile; XElement xmlRoot = Tools.LoadXml(path); foreach (var shopXml in xmlRoot.Elements("sellshop")) { SellShop shop = new SellShop(); shop.Name = Tools.GetXmlAttribute(shopXml, "name"); shop.PicUrl = ResourceManager.Get(Tools.GetXmlAttribute(shopXml, "pic")); shop.Music = Tools.GetXmlAttribute(shopXml, "music"); Shops.Add(shop); } } }
static public void Init() { Items.Clear(); ItemTriggerDb.Clear(); foreach (var itemXmlFile in GameProject.GetFiles("item")) { XElement xmlRoot = Tools.LoadXml("Scripts/" + itemXmlFile); if (xmlRoot.Name == "items") { foreach (XElement node in Tools.GetXmlElements(xmlRoot, "item")) { Items.Add(Item.Parse(node)); } } else if (xmlRoot.Name == "item_triggers") { foreach (XElement node in Tools.GetXmlElements(xmlRoot, "item_trigger")) { ItemTriggerDb.Add(ITTriggerDb.Parse(node)); } } } }
static public void Init() { bigMaps.Clear(); foreach (var eventXmlFile in GameProject.GetFiles("map")) { XElement xmlRoot = Tools.LoadXml("Scripts/" + eventXmlFile); XElement mapsRoot = Tools.GetXmlElement(xmlRoot, "maps"); if (mapsRoot == null || mapsRoot.Element("map") == null) { continue; } foreach (var map in Tools.GetXmlElements(mapsRoot, "map")) { BigMap bigMap = new BigMap(); bigMap.Name = Tools.GetXmlAttribute(map, "name"); //只抓取大地图的位置信息,其他的抓取人物信息 if (bigMap.Name != "大地图") { continue; } bigMap.xmlNode = map; bigMap.Pic = Tools.GetXmlAttribute(map, "pic"); foreach (var music in map.Element("musics").Elements("music")) { bigMap.Musics.Add(Tools.GetXmlAttribute(music, "name")); } foreach (XElement t in map.Elements("location")) { string name = Tools.GetXmlAttribute(t, "name"); Location location = new Location(); location.name = name; location.description = Tools.GetXmlAttribute(t, "description"); location.x = Tools.GetXmlAttributeInt(t, "x"); location.y = Tools.GetXmlAttributeInt(t, "y"); bigMap.locationList.Add(location); foreach (XElement eventX in t.Elements("event")) { location.events.Add(Event.Parse(eventX)); } } bigMaps.Add(bigMap); } foreach (var map in Tools.GetXmlElements(mapsRoot, "map")) { BigMap bigMap = new BigMap(); bigMap.xmlNode = map; bigMap.Name = Tools.GetXmlAttribute(map, "name"); if (map.Attribute("desc") != null) { bigMap.desc = Tools.GetXmlAttribute(map, "desc"); } //抓取人物信息 if (bigMap.Name == "大地图") { continue; } bigMap.Pic = Tools.GetXmlAttribute(map, "pic"); if (map.Element("musics") != null) { foreach (var music in map.Element("musics").Elements("music")) { bigMap.Musics.Add(Tools.GetXmlAttribute(music, "name")); } } foreach (XElement t in map.Elements("maprole")) { string roleKey = Tools.GetXmlAttribute(t, "roleKey"); MapRole mapRole = new MapRole(); mapRole.roleKey = roleKey; if (t.Attribute("pic") != null) { mapRole.pic = Tools.GetXmlAttribute(t, "pic"); } if (t.Attribute("description") != null) { mapRole.description = Tools.GetXmlAttribute(t, "description"); } if (t.Attribute("hide") != null) { if (Tools.GetXmlAttributeInt(t, "hide") == 0) { mapRole.hide = false; } } bigMap.roleList.Add(mapRole); foreach (XElement eventX in t.Elements("event")) { mapRole.events.Add(Event.Parse(eventX)); } } bigMaps.Add(bigMap); } } if (Configer.Instance.Debug) { App.DebugPanel.InitMaps(bigMaps); } }
public static void Init() { project = AnimationProject.Load(GameProject.GetFiles("animation")); }
public static void init() { talentDic.Clear(); foreach (string talentXmlFile in GameProject.GetFiles("talent")) { XElement xmlRoot = Tools.LoadXml("Scripts/" + talentXmlFile); foreach (var roleTalentNode in xmlRoot.Elements("roleTalent")) { RoleTalent roleTalent = new RoleTalent(); roleTalent.key = Tools.GetXmlAttribute(roleTalentNode, "key"); roleTalent.talents = new List <Talent>(); foreach (var talentNode in roleTalentNode.Elements("talent")) { Talent talent = new Talent(); talent.conditions = new List <TalentCondition>(); talent.effects = new List <TalentEffect>(); foreach (var conditionNode in talentNode.Elements("condition")) { TalentCondition talentCondition = new TalentCondition(); talentCondition.type = Tools.GetXmlAttribute(conditionNode, "type"); talentCondition.value = Tools.GetXmlAttribute(conditionNode, "value"); talent.conditions.Add(talentCondition); } foreach (var effectNode in talentNode.Elements("effect")) { TalentEffect talentEffect = new TalentEffect(); talentEffect.type = Tools.GetXmlAttribute(effectNode, "type"); talentEffect.value = Tools.GetXmlAttribute(effectNode, "value"); //判断类别 switch (talentEffect.type) { case "攻击加成": talentEffect.effectEnum = TalentEffectEnum.attackEffect; break; case "防御加成": talentEffect.effectEnum = TalentEffectEnum.defenceEffect; break; default: talentEffect.effectEnum = TalentEffectEnum.other; break; } talent.effects.Add(talentEffect); if (!talent.effectEnum.Contains(talentEffect.effectEnum)) { talent.effectEnum.Add(talentEffect.effectEnum); } } if (talentNode.Element("showword") != null) { talent.showword = new Showword(); XElement showwordNode = talentNode.Element("showword"); if (showwordNode.Attribute("probability") != null) { talent.showword.probability = Tools.GetXmlAttributeFloat(showwordNode, "probability"); } foreach (var wordNode in showwordNode.Elements("word")) { talent.showword.word.Add(Tools.GetXmlAttribute(wordNode, "value")); } } roleTalent.talents.Add(talent); } talentDic.Add(roleTalent.key, roleTalent); } } }
static public void Init() { Towers.Clear(); Conditions.Clear(); BonusItems.Clear(); TowerDesc.Clear(); foreach (var mapXmlFile in GameProject.GetFiles("tower")) { XElement xmlRoot = Tools.LoadXml("Scripts/" + mapXmlFile); foreach (XElement node in xmlRoot.Elements("tower")) { string key = Tools.GetXmlAttribute(node, "key"); int number = Tools.GetXmlAttributeInt(node, "number"); if (node.Attribute("desc") != null) { TowerDesc[key] = Tools.GetXmlAttribute(node, "desc"); } List <Battle> battles = new List <Battle>(); battles.Clear(); battles.Capacity = number; foreach (XElement map in node.Element("maps").Elements("map")) { String battleKey = Tools.GetXmlAttribute(map, "key"); int index = Tools.GetXmlAttributeInt(map, "index"); battles.Add(BattleManager.GetBattle(battleKey)); //处理奖励物品 List <BonusItem> items = new List <BonusItem>(); items.Clear(); foreach (XElement item in map.Elements("item")) { string itemKey = Tools.GetXmlAttribute(item, "key"); int itemNumber = 0; double itemProb = 1.0; if (item.Attribute("number") != null) { itemNumber = Tools.GetXmlAttributeInt(item, "number"); } if (item.Attribute("probability") != null) { itemProb = (double)Tools.GetXmlAttributeFloat(item, "probability"); } items.Add(new BonusItem(itemKey, itemNumber, itemProb)); } BonusItems.Add(battleKey, items); } Towers.Add(key, battles); //开启天关的条件 List <EventCondition> conditions = new List <EventCondition>(); conditions.Clear(); foreach (XElement condition in node.Element("conditions").Elements("condition")) { EventCondition cond = new EventCondition(); cond.type = Tools.GetXmlAttribute(condition, "type"); cond.value = Tools.GetXmlAttribute(condition, "value"); if (condition.Attribute("number") != null) { cond.number = Tools.GetXmlAttributeInt(condition, "number"); } conditions.Add(cond); } Conditions.Add(key, conditions); } } }